|
| 1 | +import { jest } from '@jest/globals'; |
1 | 2 | import * as fc from 'fast-check';
|
2 |
| -import { typedIntArrayArbitraryArbitraryBuilder } from '../../../../../src/arbitrary/_internals/builders/TypedIntArrayArbitraryBuilder'; |
3 | 3 |
|
4 |
| -import { FakeIntegerArbitrary, fakeArbitrary, fakeArbitraryStaticValue } from '../../__test-helpers__/ArbitraryHelpers'; |
| 4 | +jest.unstable_mockModule('./src/arbitrary/array', () => ({ |
| 5 | + array: jest.fn(), |
| 6 | +})); |
5 | 7 |
|
6 |
| -import * as ArrayMock from '../../../../../src/arbitrary/array'; |
7 |
| -import { |
| 8 | +const { typedIntArrayArbitraryArbitraryBuilder } = await import( |
| 9 | + '../../../../../src/arbitrary/_internals/builders/TypedIntArrayArbitraryBuilder' |
| 10 | +); |
| 11 | + |
| 12 | +const { FakeIntegerArbitrary, fakeArbitrary, fakeArbitraryStaticValue } = await import( |
| 13 | + '../../__test-helpers__/ArbitraryHelpers' |
| 14 | +); |
| 15 | +const { |
8 | 16 | assertProduceCorrectValues,
|
9 | 17 | assertProduceSameValueGivenSameSeed,
|
10 | 18 | assertProduceValuesShrinkableWithoutContext,
|
11 | 19 | assertShrinkProducesSameValueWithoutInitialContext,
|
12 |
| -} from '../../__test-helpers__/ArbitraryAssertions'; |
| 20 | +} = await import('../../__test-helpers__/ArbitraryAssertions'); |
13 | 21 |
|
14 |
| -function beforeEachHook() { |
15 |
| - jest.resetModules(); |
16 |
| - jest.restoreAllMocks(); |
17 |
| - fc.configureGlobal({ beforeEach: beforeEachHook }); |
18 |
| -} |
19 |
| -beforeEach(beforeEachHook); |
| 22 | +const ArrayMock = await import('../../../../../src/arbitrary/array'); |
20 | 23 |
|
21 | 24 | describe('typedIntArrayArbitraryArbitraryBuilder', () => {
|
| 25 | + function beforeEachHook() { |
| 26 | + jest.resetAllMocks(); |
| 27 | + } |
| 28 | + fc.configureGlobal({ beforeEach: beforeEachHook }); |
| 29 | + beforeEach(beforeEachHook); |
| 30 | + |
22 | 31 | it('should default constraints for arbitraryBuilder to defaultMin/Max when not specified', () => {
|
23 | 32 | fc.assert(
|
24 | 33 | fc.property(
|
@@ -123,6 +132,13 @@ describe('typedIntArrayArbitraryArbitraryBuilder', () => {
|
123 | 132 | });
|
124 | 133 |
|
125 | 134 | describe('typedIntArrayArbitraryArbitraryBuilder (integration)', () => {
|
| 135 | + function beforeEachHook() { |
| 136 | + jest.resetAllMocks(); |
| 137 | + jest.spyOn(ArrayMock, 'array').mockImplementation(jest.requireActual('./lib/cjs/arbitrary/array').array); |
| 138 | + } |
| 139 | + fc.configureGlobal({ beforeEach: beforeEachHook }); |
| 140 | + beforeEach(beforeEachHook); |
| 141 | + |
126 | 142 | type Extra = { minLength?: number; maxLength?: number; min?: number; max?: number };
|
127 | 143 | const extraParameters: fc.Arbitrary<Extra> = fc
|
128 | 144 | .record(
|
|
0 commit comments