-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: fields with boolean values should be considered empty only if no…
… value is set
- Loading branch information
Showing
5 changed files
with
52 additions
and
16 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
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
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
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,22 @@ | ||
import { createModel } from '../src/FormModel'; | ||
|
||
describe('FormModel with boolean fields', () => { | ||
it('it should not complain value is required if value is set to a boolean', async () => { | ||
const model = createModel({ | ||
descriptors: { name: {}, lastName: {}, isFunny: { required: true } }, | ||
initialState: { name: 'Snoopy', lastName: 'Brown' }, | ||
}); | ||
|
||
expect(model.fields.isFunny.value).toEqual(undefined); | ||
|
||
await model.validate(); | ||
|
||
expect(model.fields.isFunny.errorMessage).toMatchInlineSnapshot('"Field: \\"isFunny\\" is required"'); | ||
|
||
model.fields.isFunny.setValue(false); | ||
|
||
await model.validate(); | ||
|
||
expect(model.fields.isFunny.errorMessage).toEqual(undefined); | ||
}); | ||
}); |
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