-
-
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
11 changed files
with
179 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import wait from 'wait'; | ||
|
||
import { dummyTest } from '../../../../testUtils/testDummy'; | ||
|
||
import vest from 'vest'; | ||
|
||
describe('suite.remove', () => { | ||
it('Should remove field from validation result', async () => { | ||
const suite = vest.create(() => { | ||
dummyTest.failing('field1'); | ||
dummyTest.failing('field1'); | ||
dummyTest.failingAsync('field1', { time: 100 }); | ||
dummyTest.failing('field2'); | ||
dummyTest.passing('field2'); | ||
dummyTest.passing('field1'); | ||
}); | ||
suite(); | ||
expect(suite.get().testCount).toBe(6); | ||
expect(suite.get().tests.field1.testCount).toBe(4); | ||
expect(suite.get().tests.field2.testCount).toBe(2); | ||
suite.remove('field1'); | ||
expect(suite.get().testCount).toBe(2); | ||
expect(suite.get().tests.field1).toBeUndefined(); | ||
await wait(150); | ||
expect(suite.get().testCount).toBe(2); | ||
expect(suite.get().tests.field1).toBeUndefined(); | ||
}); | ||
|
||
it('Should clear the cache when removing a field', () => { | ||
const suite = vest.create(() => { | ||
dummyTest.failing('field1'); | ||
dummyTest.failing('field2'); | ||
}); | ||
suite(); | ||
const res = suite.get(); | ||
suite.remove('field2'); | ||
expect(suite.get()).not.toBe(res); | ||
}); | ||
|
||
it('Should return silently when removing a field that does not exist', () => { | ||
const suite = vest.create(() => { | ||
dummyTest.failing('field1'); | ||
dummyTest.passing('field2'); | ||
}); | ||
suite(); | ||
const res = suite.get(); | ||
suite.remove('field3'); | ||
expect(suite.get()).toBe(res); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import asArray from 'asArray'; | ||
import removeElementFromArray from 'removeElementFromArray'; | ||
import useTestObjects from 'useTestObjects'; | ||
|
||
/** | ||
* Removes test object from suite state | ||
* @param {VestTest} testObject | ||
*/ | ||
export default testObject => { | ||
useTestObjects(testObjects => | ||
// using asArray to clear the cache. | ||
asArray(removeElementFromArray(testObjects, testObject)) | ||
); | ||
}; |