-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/features/linodes/LinodesCreate/TabbedContent/formUtilities.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { images, privateImages } from 'src/__data__/images'; | ||
import { filterPublicImages, filterUDFErrors } from './formUtilities'; | ||
|
||
describe('Linode Create Utilities', () => { | ||
it('should filter out public Images', () => { | ||
const filteredImages = filterPublicImages([...images, ...privateImages]); | ||
expect( | ||
filteredImages.every(eachImage => !!eachImage.is_public) | ||
).toBeTruthy(); | ||
}); | ||
|
||
it('should filter out all errors except UDF errors', () => { | ||
const mockErrors: Linode.ApiFieldError[] = [ | ||
{ | ||
field: 'label', | ||
reason: 'label is required' | ||
}, | ||
{ | ||
field: 'ssh_keys', | ||
reason: 'ssh_keys are required' | ||
}, | ||
{ | ||
field: 'wp_password', | ||
reason: 'a value for the UDF is required' | ||
} | ||
]; | ||
|
||
const errorResources = { | ||
label: 'A label', | ||
ssh_keys: 'ssh_keys' | ||
}; | ||
|
||
const filteredErrors = filterUDFErrors(errorResources, mockErrors); | ||
expect(filteredErrors[0].field).toBe('wp_password'); | ||
expect(filteredErrors).toHaveLength(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters