-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ESSNTL-5418): Trim group name before validate (#2105)
- Loading branch information
Showing
2 changed files
with
37 additions
and
11 deletions.
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
25 changes: 25 additions & 0 deletions
25
src/components/InventoryGroups/Modals/CreateGroupModal.test.js
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,25 @@ | ||
import { validateGroupName } from '../utils/api'; | ||
import { validate } from './CreateGroupModal'; | ||
|
||
jest.mock('../utils/api'); | ||
|
||
describe('validate function', () => { | ||
it('works with basic input', async () => { | ||
const result = await validate('test'); | ||
|
||
expect(result).toBe(undefined); | ||
expect(validateGroupName).toHaveBeenCalledWith('test'); | ||
}); | ||
|
||
it('trims input', async () => { | ||
const result = await validate(' test '); | ||
|
||
expect(result).toBe(undefined); | ||
expect(validateGroupName).toHaveBeenCalledWith('test'); | ||
}); | ||
|
||
it('throws error if the name is present', async () => { | ||
validateGroupName.mockResolvedValue(true); | ||
await expect(validate('test')).rejects.toBe('Group name already exists'); | ||
}); | ||
}); |