vest 5.0.0-dev-781e21 → 5.0.2-dev-d315d9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +2 -57
- package/dist/cjs/classnames.development.js +18 -16
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compose.development.js +5 -54
- package/dist/cjs/enforce/compose.production.js +1 -1
- package/dist/cjs/enforce/compounds.development.js +20 -83
- package/dist/cjs/enforce/compounds.production.js +1 -1
- package/dist/cjs/enforce/schema.development.js +19 -82
- package/dist/cjs/enforce/schema.production.js +1 -1
- package/dist/cjs/parser.development.js +12 -9
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/promisify.development.js +4 -8
- package/dist/cjs/promisify.production.js +1 -1
- package/dist/cjs/vest.development.js +1287 -1153
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +20 -18
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/enforce/compose.development.js +1 -58
- package/dist/es/enforce/compose.production.js +1 -1
- package/dist/es/enforce/compounds.development.js +2 -90
- package/dist/es/enforce/compounds.production.js +1 -1
- package/dist/es/enforce/schema.development.js +2 -88
- package/dist/es/enforce/schema.production.js +1 -1
- package/dist/es/parser.development.js +12 -9
- package/dist/es/parser.production.js +1 -1
- package/dist/es/promisify.development.js +5 -9
- package/dist/es/promisify.production.js +1 -1
- package/dist/es/vest.development.js +1286 -1148
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +21 -19
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +9 -57
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +32 -94
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +32 -94
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +16 -13
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/promisify.development.js +7 -11
- package/dist/umd/promisify.production.js +1 -1
- package/dist/umd/vest.development.js +1289 -1155
- package/dist/umd/vest.production.js +1 -1
- package/package.json +12 -16
- package/src/__tests__/__snapshots__/integration.async-tests.test.ts.snap +71 -0
- package/src/__tests__/__snapshots__/integration.base.test.ts.snap +71 -0
- package/src/__tests__/__snapshots__/integration.stateful-async.test.ts.snap +243 -0
- package/src/__tests__/__snapshots__/integration.stateful-tests.test.ts.snap +376 -0
- package/src/__tests__/integration.async-tests.test.ts +90 -0
- package/src/__tests__/integration.base.test.ts +45 -0
- package/src/__tests__/integration.exclusive.test.ts +88 -0
- package/src/__tests__/integration.stateful-async.test.ts +137 -0
- package/src/__tests__/integration.stateful-tests.test.ts +155 -0
- package/src/__tests__/isolate.test.ts +288 -0
- package/src/__tests__/state_refill.test.ts +41 -0
- package/src/core/SuiteWalker/SuiteWalker.ts +64 -0
- package/src/core/SuiteWalker/__tests__/hasRemainingTests.test.ts +130 -0
- package/src/core/VestBus/VestBus.ts +78 -0
- package/src/core/context/PersistedContext.ts +243 -0
- package/src/core/context/SuiteContext.ts +74 -0
- package/src/core/isolate/IsolateTest/IsolateTest.ts +213 -0
- package/src/core/isolate/IsolateTest/IsolateTestReconciler.ts +156 -0
- package/src/core/isolate/IsolateTest/IsolateTestStateMachine.ts +69 -0
- package/src/core/isolate/IsolateTest/SimpleStateMachine.ts +43 -0
- package/src/core/isolate/IsolateTest/TestWalker.ts +77 -0
- package/src/core/isolate/IsolateTypes.ts +10 -0
- package/src/core/isolate/isIsolate.ts +6 -0
- package/src/core/isolate/isolate.ts +110 -0
- package/src/core/isolate/reconciler/Reconciler/Reconciler.ts +123 -0
- package/src/core/isolate/reconciler/cancelOverriddenPendingTest.ts +15 -0
- package/src/core/isolate/reconciler/isSameProfileTest.ts +12 -0
- package/src/core/isolate/walker.ts +127 -0
- package/src/core/test/TestTypes.ts +3 -0
- package/src/core/test/__tests__/IsolateTest.test.ts +152 -0
- package/src/core/test/__tests__/__snapshots__/IsolateTest.test.ts.snap +39 -0
- package/src/core/test/__tests__/__snapshots__/memo.test.ts.snap +101 -0
- package/src/core/test/__tests__/__snapshots__/test.test.ts.snap +231 -0
- package/src/core/test/__tests__/key.test.ts +195 -0
- package/src/core/test/__tests__/memo.test.ts +218 -0
- package/src/core/test/__tests__/merging_of_previous_test_runs.test.ts +341 -0
- package/src/core/test/__tests__/runAsyncTest.test.ts +175 -0
- package/src/core/test/__tests__/test.test.ts +226 -0
- package/src/core/test/helpers/__tests__/nonMatchingSeverityProfile.test.ts +52 -0
- package/src/core/test/helpers/asVestTest.ts +9 -0
- package/src/core/test/helpers/matchingFieldName.ts +16 -0
- package/src/core/test/helpers/matchingGroupName.ts +12 -0
- package/src/core/test/helpers/nonMatchingSeverityProfile.ts +14 -0
- package/src/core/test/helpers/shouldUseErrorMessage.ts +9 -0
- package/src/core/test/test.memo.ts +81 -0
- package/src/core/test/test.ts +64 -0
- package/src/core/test/testLevelFlowControl/runTest.ts +86 -0
- package/src/core/test/testLevelFlowControl/verifyTestRun.ts +32 -0
- package/src/core/test/testObjectIsolate.ts +11 -0
- package/src/errors/ErrorStrings.ts +4 -0
- package/src/exports/__tests__/classnames.test.ts +92 -0
- package/src/exports/__tests__/parser.test.ts +441 -0
- package/src/exports/__tests__/promisify.test.ts +77 -0
- package/src/exports/classnames.ts +35 -0
- package/src/exports/enforce@compose.ts +1 -0
- package/src/exports/enforce@compounds.ts +1 -0
- package/src/exports/enforce@schema.ts +1 -0
- package/src/exports/parser.ts +63 -0
- package/src/exports/promisify.ts +18 -0
- package/src/hooks/__tests__/__snapshots__/include.test.ts.snap +794 -0
- package/src/hooks/__tests__/eager.test.ts +130 -0
- package/src/hooks/__tests__/exclusive.test.ts +578 -0
- package/src/hooks/__tests__/include.test.ts +431 -0
- package/src/hooks/__tests__/optional.test.ts +83 -0
- package/src/hooks/__tests__/warn.test.ts +42 -0
- package/src/hooks/exclusive.ts +179 -0
- package/src/hooks/include.ts +54 -0
- package/src/hooks/mode.ts +47 -0
- package/src/hooks/optional/OptionalTypes.ts +31 -0
- package/src/hooks/optional/optional.ts +69 -0
- package/src/hooks/warn.ts +19 -0
- package/src/isolates/__tests__/__snapshots__/each.test.ts.snap +3 -0
- package/src/isolates/__tests__/__snapshots__/group.test.ts.snap +114 -0
- package/src/isolates/__tests__/__snapshots__/omitWhen.test.ts.snap +443 -0
- package/src/isolates/__tests__/__snapshots__/skipWhen.test.ts.snap +99 -0
- package/src/isolates/__tests__/each.test.ts +35 -0
- package/src/isolates/__tests__/group.test.ts +362 -0
- package/src/isolates/__tests__/omitWhen.test.ts +246 -0
- package/src/isolates/__tests__/skipWhen.test.ts +163 -0
- package/src/isolates/each.ts +30 -0
- package/src/isolates/group.ts +9 -0
- package/src/isolates/omitWhen.ts +41 -0
- package/src/isolates/skipWhen.ts +42 -0
- package/src/suite/__tests__/__snapshots__/create.test.ts.snap +67 -0
- package/src/suite/__tests__/create.test.ts +109 -0
- package/src/suite/__tests__/remove.test.ts +50 -0
- package/src/suite/__tests__/resetField.test.ts +74 -0
- package/src/suite/createSuite.ts +94 -0
- package/src/suite/runCallbacks.ts +28 -0
- package/src/suiteResult/Severity.ts +15 -0
- package/src/suiteResult/SuiteResultTypes.ts +42 -0
- package/src/suiteResult/__tests__/done.test.ts +334 -0
- package/src/suiteResult/__tests__/produce.test.ts +163 -0
- package/src/suiteResult/done/deferDoneCallback.ts +28 -0
- package/src/suiteResult/done/shouldSkipDoneRegistration.ts +20 -0
- package/src/suiteResult/selectors/__tests__/__snapshots__/collectFailureMessages.test.ts.snap +89 -0
- package/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts +124 -0
- package/src/suiteResult/selectors/__tests__/getFailures.test.ts +158 -0
- package/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts +199 -0
- package/src/suiteResult/selectors/__tests__/hasFailures.test.ts +141 -0
- package/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts +185 -0
- package/src/suiteResult/selectors/__tests__/hasFailuresByTestObject.test.ts +88 -0
- package/src/suiteResult/selectors/__tests__/isValid.test.ts +359 -0
- package/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts +480 -0
- package/src/suiteResult/selectors/collectFailures.ts +43 -0
- package/src/suiteResult/selectors/hasFailuresByTestObjects.ts +62 -0
- package/src/suiteResult/selectors/produceSuiteSummary.ts +135 -0
- package/src/suiteResult/selectors/shouldAddValidProperty.ts +148 -0
- package/src/suiteResult/selectors/suiteSelectors.ts +199 -0
- package/src/suiteResult/suiteResult.ts +15 -0
- package/src/suiteResult/suiteRunResult.ts +43 -0
- package/src/vest.ts +36 -0
- package/testUtils/TVestMock.ts +5 -0
- package/testUtils/__tests__/partition.test.ts +4 -4
- package/testUtils/mockThrowError.ts +4 -2
- package/testUtils/suiteDummy.ts +2 -1
- package/testUtils/testDummy.ts +12 -10
- package/testUtils/testPromise.ts +3 -0
- package/tsconfig.json +84 -2
- package/types/classnames.d.ts +39 -4
- package/types/classnames.d.ts.map +1 -0
- package/types/enforce/compose.d.ts +2 -126
- package/types/enforce/compose.d.ts.map +1 -0
- package/types/enforce/compounds.d.ts +2 -136
- package/types/enforce/compounds.d.ts.map +1 -0
- package/types/enforce/schema.d.ts +2 -144
- package/types/enforce/schema.d.ts.map +1 -0
- package/types/parser.d.ts +45 -10
- package/types/parser.d.ts.map +1 -0
- package/types/promisify.d.ts +36 -34
- package/types/promisify.d.ts.map +1 -0
- package/types/vest.d.ts +169 -224
- package/types/vest.d.ts.map +1 -0
- package/CHANGELOG.md +0 -87
- package/testUtils/expandStateRef.ts +0 -8
- package/testUtils/runCreateRef.ts +0 -10
- package/testUtils/testObjects.ts +0 -6
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import wait from 'wait';
|
|
2
|
+
|
|
3
|
+
import { TestPromise } from '../../../../testUtils/testPromise';
|
|
4
|
+
|
|
5
|
+
import { TTestSuite } from 'testUtils/TVestMock';
|
|
6
|
+
import { test, optional, create, skipWhen, warn, skip, only } from 'vest';
|
|
7
|
+
|
|
8
|
+
describe('isValid', () => {
|
|
9
|
+
describe('Before any test ran', () => {
|
|
10
|
+
it('Should return false', () => {
|
|
11
|
+
const suite = create(() => {
|
|
12
|
+
test('field_1', () => false);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
expect(suite.get().isValid()).toBe(false);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('When there are errors in the suite', () => {
|
|
20
|
+
let suite: TTestSuite;
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
suite = create((fieldToSkip: string) => {
|
|
24
|
+
skip(fieldToSkip);
|
|
25
|
+
optional('field_1');
|
|
26
|
+
|
|
27
|
+
test('field_1', () => false);
|
|
28
|
+
test('field_2', () => false);
|
|
29
|
+
test('sanity', () => true);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('Should return false when an optional test has errors', () => {
|
|
34
|
+
expect(suite('field_2').isValid()).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
it('Should return false when a required test has errors', () => {
|
|
37
|
+
expect(suite('field_1').isValid()).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('Should return false when the queried field is not optional and has errors', () => {
|
|
41
|
+
expect(suite('field_2').isValid('field_2')).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('Should return true when the queried field is optional and has errors', () => {
|
|
45
|
+
expect(suite('field_1').isValid('field_1')).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('When there are warnings in the suite', () => {
|
|
50
|
+
let suite: TTestSuite;
|
|
51
|
+
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
suite = create(() => {
|
|
54
|
+
test('field_1', () => {
|
|
55
|
+
warn();
|
|
56
|
+
return false;
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
it('Should return true when a required test has warnings', () => {
|
|
61
|
+
expect(suite().isValid()).toBe(true);
|
|
62
|
+
expect(suite().isValid('field_1')).toBe(true);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('When some of the tests for the required field are warnings', () => {
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
suite = create(() => {
|
|
68
|
+
test('field_1', () => {
|
|
69
|
+
warn();
|
|
70
|
+
return false;
|
|
71
|
+
});
|
|
72
|
+
test('field_1', () => true);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
it('Should return true when a required test has warnings', () => {
|
|
76
|
+
expect(suite().isValid()).toBe(true);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('when a warning test in a required field is skipped', () => {
|
|
81
|
+
beforeEach(() => {
|
|
82
|
+
suite = create(() => {
|
|
83
|
+
test('field_1', () => true);
|
|
84
|
+
|
|
85
|
+
skipWhen(true, () => {
|
|
86
|
+
test('field_1', () => {
|
|
87
|
+
warn();
|
|
88
|
+
return false;
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
it('Should return false even when the skipped field is warning', () => {
|
|
94
|
+
expect(suite().isValid()).toBe(false);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe('When a non optional field is skipped', () => {
|
|
100
|
+
let suite: TTestSuite;
|
|
101
|
+
|
|
102
|
+
beforeEach(() => {
|
|
103
|
+
suite = create(fieldToSkip => {
|
|
104
|
+
skip(fieldToSkip);
|
|
105
|
+
test('field_1', () => {
|
|
106
|
+
return false;
|
|
107
|
+
});
|
|
108
|
+
test('field_2', () => {
|
|
109
|
+
return true;
|
|
110
|
+
});
|
|
111
|
+
test('field_3', () => {
|
|
112
|
+
return true;
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
it('Should return false', () => {
|
|
117
|
+
expect(suite('field_1').isValid()).toBe(false);
|
|
118
|
+
});
|
|
119
|
+
it('Should return false', () => {
|
|
120
|
+
expect(suite(['field_2', 'field_3']).isValid()).toBe(false);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('When the suite has an async optional test', () => {
|
|
125
|
+
let suite: TTestSuite;
|
|
126
|
+
|
|
127
|
+
beforeEach(() => {
|
|
128
|
+
suite = create(() => {
|
|
129
|
+
optional('field_1');
|
|
130
|
+
test('field_1', async () => {
|
|
131
|
+
await wait(300);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('When test is pending', () => {
|
|
137
|
+
it('Should return true', () => {
|
|
138
|
+
suite();
|
|
139
|
+
expect(suite.get().isValid()).toBe(true);
|
|
140
|
+
expect(suite.get().isValid('field_1')).toBe(true);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
describe('When test is passing', () => {
|
|
144
|
+
it('Should return true', async () => {
|
|
145
|
+
suite();
|
|
146
|
+
await wait(300);
|
|
147
|
+
expect(suite.get().isValid()).toBe(true);
|
|
148
|
+
expect(suite.get().isValid('field_1')).toBe(true);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
describe('When the suite has warning async tests', () => {
|
|
154
|
+
let suite: TTestSuite;
|
|
155
|
+
|
|
156
|
+
beforeEach(() => {
|
|
157
|
+
suite = create(() => {
|
|
158
|
+
test('field_1', async () => {
|
|
159
|
+
warn();
|
|
160
|
+
await wait(300);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test('field_1', () => {
|
|
164
|
+
return true;
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('Should return false as long as the test is pending', async () => {
|
|
170
|
+
suite();
|
|
171
|
+
expect(suite.get().isValid()).toBe(false);
|
|
172
|
+
await wait(300);
|
|
173
|
+
expect(suite.get().isValid()).toBe(true);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('Should return false as long as the test is pending when querying a specific field', async () => {
|
|
177
|
+
suite();
|
|
178
|
+
expect(suite.get().isValid('field_1')).toBe(false);
|
|
179
|
+
await wait(300);
|
|
180
|
+
expect(suite.get().isValid('field_1')).toBe(true);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe('When the suite has async non-optional tests', () => {
|
|
185
|
+
let suite: TTestSuite;
|
|
186
|
+
|
|
187
|
+
beforeEach(() => {
|
|
188
|
+
suite = create(currentField => {
|
|
189
|
+
only(currentField);
|
|
190
|
+
optional('field_2');
|
|
191
|
+
test('field_1', async () => {
|
|
192
|
+
await wait(300);
|
|
193
|
+
});
|
|
194
|
+
test('field_2', () => {
|
|
195
|
+
return true;
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
describe('When test is pending', () => {
|
|
201
|
+
it('Should return `false` for a required field', () => {
|
|
202
|
+
const result = suite();
|
|
203
|
+
|
|
204
|
+
expect(result.isValid()).toBe(false);
|
|
205
|
+
expect(result.isValid('field_1')).toBe(false);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
describe('When async test is passing', () => {
|
|
210
|
+
it('Should return `true`', () => {
|
|
211
|
+
return TestPromise(done => {
|
|
212
|
+
suite().done(result => {
|
|
213
|
+
expect(result.isValid()).toBe(true);
|
|
214
|
+
expect(result.isValid('field_1')).toBe(true);
|
|
215
|
+
expect(result.isValid('field_2')).toBe(true);
|
|
216
|
+
done();
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
describe('When test is lagging', () => {
|
|
223
|
+
it('Should return `false`', () => {
|
|
224
|
+
suite();
|
|
225
|
+
const result = suite('field_2');
|
|
226
|
+
|
|
227
|
+
expect(result.isValid()).toBe(false);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
describe('When a all required fields are passing', () => {
|
|
233
|
+
let suite: TTestSuite;
|
|
234
|
+
|
|
235
|
+
beforeEach(() => {
|
|
236
|
+
suite = create(() => {
|
|
237
|
+
test('field_1', () => {
|
|
238
|
+
return true;
|
|
239
|
+
});
|
|
240
|
+
test('field_1', () => {
|
|
241
|
+
return true;
|
|
242
|
+
});
|
|
243
|
+
test('field_2', () => {
|
|
244
|
+
return true;
|
|
245
|
+
});
|
|
246
|
+
test('field_3', () => {
|
|
247
|
+
return true;
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
it('Should return true', () => {
|
|
252
|
+
expect(suite().isValid()).toBe(true);
|
|
253
|
+
expect(suite().isValid('field_1')).toBe(true);
|
|
254
|
+
expect(suite().isValid('field_2')).toBe(true);
|
|
255
|
+
expect(suite().isValid('field_3')).toBe(true);
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
describe('When a required field has some passing tests', () => {
|
|
260
|
+
it('Should return false', () => {
|
|
261
|
+
expect(
|
|
262
|
+
create(() => {
|
|
263
|
+
test('field_1', () => true);
|
|
264
|
+
skipWhen(true, () => {
|
|
265
|
+
test('field_1', () => {
|
|
266
|
+
return true;
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
})().isValid()
|
|
270
|
+
).toBe(false);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
describe('When field name is specified', () => {
|
|
275
|
+
it('Should return false when field did not run yet', () => {
|
|
276
|
+
expect(
|
|
277
|
+
create(() => {
|
|
278
|
+
skip('field_1');
|
|
279
|
+
test('field_1', () => true);
|
|
280
|
+
})().isValid('field_1')
|
|
281
|
+
).toBe(false);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it('Should return false when testing for a field that does not exist', () => {
|
|
285
|
+
expect(
|
|
286
|
+
create(() => {
|
|
287
|
+
test('field_1', () => {});
|
|
288
|
+
})().isValid('field 2')
|
|
289
|
+
).toBe(false);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it("Should return false when some of the field's tests ran", () => {
|
|
293
|
+
expect(
|
|
294
|
+
create(() => {
|
|
295
|
+
test('field_1', () => {
|
|
296
|
+
return true;
|
|
297
|
+
});
|
|
298
|
+
skipWhen(true, () => {
|
|
299
|
+
test('field_1', () => {
|
|
300
|
+
return true;
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
})().isValid('field_1')
|
|
304
|
+
).toBe(false);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it('Should return false when the field has errors', () => {
|
|
308
|
+
expect(
|
|
309
|
+
create(() => {
|
|
310
|
+
test('field_1', () => {
|
|
311
|
+
return false;
|
|
312
|
+
});
|
|
313
|
+
})().isValid('field_1')
|
|
314
|
+
).toBe(false);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('Should return true when all the tests are passing', () => {
|
|
318
|
+
expect(
|
|
319
|
+
create(() => {
|
|
320
|
+
test('field_1', () => {
|
|
321
|
+
return true;
|
|
322
|
+
});
|
|
323
|
+
})().isValid('field_1')
|
|
324
|
+
).toBe(true);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('Should return true when the field only has warnings', () => {
|
|
328
|
+
expect(
|
|
329
|
+
create(() => {
|
|
330
|
+
test('field_1', () => {
|
|
331
|
+
warn();
|
|
332
|
+
return false;
|
|
333
|
+
});
|
|
334
|
+
})().isValid('field_1')
|
|
335
|
+
).toBe(true);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
it('Should return true if field is optional and did not run', () => {
|
|
339
|
+
expect(
|
|
340
|
+
create(() => {
|
|
341
|
+
optional('field_1');
|
|
342
|
+
skipWhen(true, () => {
|
|
343
|
+
test('field_1', () => false);
|
|
344
|
+
});
|
|
345
|
+
})().isValid('field_1')
|
|
346
|
+
).toBe(true);
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
describe('When querying a non existing field', () => {
|
|
351
|
+
it('Should return false', () => {
|
|
352
|
+
expect(
|
|
353
|
+
create(() => {
|
|
354
|
+
test('field_1', () => true);
|
|
355
|
+
})().isValid('field_2')
|
|
356
|
+
).toBe(false);
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
});
|