|
1 |
| -/** |
2 |
| - * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. |
3 |
| - * |
4 |
| - * This source code is licensed under the MIT license found in the |
5 |
| - * LICENSE file in the root directory of this source tree. |
6 |
| - * |
7 |
| - */ |
8 |
| - |
9 |
| -import fc from 'fast-check'; |
10 |
| -import { |
11 |
| - anythingSettings, |
12 |
| - assertSettings, |
13 |
| -} from './__arbitraries__/sharedSettings'; |
14 |
| - |
15 |
| -describe('toContain', () => { |
16 |
| - it('should always find the value when inside the array', () => { |
17 |
| - fc.assert( |
18 |
| - fc.property( |
19 |
| - fc.array(fc.anything(anythingSettings)), |
20 |
| - fc.array(fc.anything(anythingSettings)), |
21 |
| - fc.anything(anythingSettings).filter(v => !Number.isNaN(v)), |
22 |
| - (startValues, endValues, v) => { |
23 |
| - // Given: startValues, endValues arrays and v value (not NaN) |
24 |
| - expect([...startValues, v, ...endValues]).toContain(v); |
25 |
| - }, |
26 |
| - ), |
27 |
| - assertSettings, |
28 |
| - ); |
29 |
| - }); |
30 |
| - |
31 |
| - it('should not find the value if it has been cloned into the array', () => { |
32 |
| - fc.assert( |
33 |
| - fc.property( |
34 |
| - fc.array(fc.anything(anythingSettings)), |
35 |
| - fc.array(fc.anything(anythingSettings)), |
36 |
| - fc.dedup(fc.anything(anythingSettings), 2), |
37 |
| - (startValues, endValues, [a, b]) => { |
38 |
| - // Given: startValues, endValues arrays |
39 |
| - // and [a, b] equal, but not the same values |
40 |
| - // with `typeof a === 'object && a !== null` |
41 |
| - fc.pre(typeof a === 'object' && a !== null); |
42 |
| - expect([...startValues, a, ...endValues]).not.toContain(b); |
43 |
| - }, |
44 |
| - ), |
45 |
| - assertSettings, |
46 |
| - ); |
47 |
| - }); |
48 |
| -}); |
| 1 | +/** |
| 2 | + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + * |
| 7 | + */ |
| 8 | + |
| 9 | +import fc from 'fast-check'; |
| 10 | +import { |
| 11 | + anythingSettings, |
| 12 | + assertSettings, |
| 13 | +} from './__arbitraries__/sharedSettings'; |
| 14 | + |
| 15 | +describe('toContain', () => { |
| 16 | + it('should always find the value when inside the array', () => { |
| 17 | + fc.assert( |
| 18 | + fc.property( |
| 19 | + fc.array(fc.anything(anythingSettings)), |
| 20 | + fc.array(fc.anything(anythingSettings)), |
| 21 | + fc.anything(anythingSettings).filter(v => !Number.isNaN(v)), |
| 22 | + (startValues, endValues, v) => { |
| 23 | + // Given: startValues, endValues arrays and v value (not NaN) |
| 24 | + expect([...startValues, v, ...endValues]).toContain(v); |
| 25 | + }, |
| 26 | + ), |
| 27 | + assertSettings, |
| 28 | + ); |
| 29 | + }); |
| 30 | + |
| 31 | + it('should not find the value if it has been cloned into the array', () => { |
| 32 | + fc.assert( |
| 33 | + fc.property( |
| 34 | + fc.array(fc.anything(anythingSettings)), |
| 35 | + fc.array(fc.anything(anythingSettings)), |
| 36 | + fc.dedup(fc.anything(anythingSettings), 2), |
| 37 | + (startValues, endValues, [a, b]) => { |
| 38 | + // Given: startValues, endValues arrays |
| 39 | + // and [a, b] equal, but not the same values |
| 40 | + // with `typeof a === 'object && a !== null` |
| 41 | + fc.pre(typeof a === 'object' && a !== null); |
| 42 | + expect([...startValues, a, ...endValues]).not.toContain(b); |
| 43 | + }, |
| 44 | + ), |
| 45 | + assertSettings, |
| 46 | + ); |
| 47 | + }); |
| 48 | +}); |
0 commit comments