-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
111 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { create, test } from 'vest'; | ||
|
||
describe('suite.resetField', () => { | ||
let suite; | ||
|
||
beforeEach(() => { | ||
suite = create(() => { | ||
test('field1', 'f1 error', () => false); | ||
test('field2', 'f2 error', () => false); | ||
}); | ||
suite(); | ||
}); | ||
|
||
it('Should reset the validity state of a field', () => { | ||
expect(suite.get().hasErrors('field1')).toBe(true); | ||
expect(suite.get().hasErrors('field2')).toBe(true); | ||
expect(suite.get().getErrors('field1')).toEqual(['f1 error']); | ||
expect(suite.get().getErrors('field2')).toEqual(['f2 error']); | ||
suite.resetField('field1'); | ||
expect(suite.get().hasErrors('field1')).toBe(false); | ||
expect(suite.get().hasErrors('field2')).toBe(true); | ||
expect(suite.get().getErrors('field1')).toEqual([]); | ||
expect(suite.get().getErrors('field2')).toEqual(['f2 error']); | ||
suite.resetField('field2'); | ||
expect(suite.get().hasErrors('field1')).toBe(false); | ||
expect(suite.get().hasErrors('field2')).toBe(false); | ||
expect(suite.get().getErrors('field1')).toEqual([]); | ||
expect(suite.get().getErrors('field2')).toEqual([]); | ||
}); | ||
|
||
it('Should refresh the suite result', () => { | ||
const res = suite.get(); | ||
expect(res).toBe(suite.get()); | ||
suite.resetField('field1'); | ||
expect(res).not.toBe(suite.get()); | ||
}); | ||
|
||
it('Should allow the field to keep updating (no final status)', () => { | ||
suite.resetField('field1'); | ||
expect(suite.get().hasErrors('field1')).toBe(false); | ||
expect(suite.get().hasErrors('field2')).toBe(true); | ||
suite(); | ||
expect(suite.get().hasErrors('field1')).toBe(true); | ||
expect(suite.get().hasErrors('field2')).toBe(true); | ||
}); | ||
|
||
it('sanity', () => { | ||
expect(suite.get().tests).toMatchInlineSnapshot(` | ||
Object { | ||
"field1": Object { | ||
"errorCount": 1, | ||
"errors": Array [ | ||
"f1 error", | ||
], | ||
"testCount": 1, | ||
"warnCount": 0, | ||
}, | ||
"field2": Object { | ||
"errorCount": 1, | ||
"errors": Array [ | ||
"f2 error", | ||
], | ||
"testCount": 1, | ||
"warnCount": 0, | ||
}, | ||
} | ||
`); | ||
}); | ||
}); |
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
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
c1e31f3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
vest-next – ./website
vest-next-ealush.vercel.app
vest-website.vercel.app
vest-next-git-latest-ealush.vercel.app
vest-next.vercel.app