diff --git a/test/e2e/SkipAllAfterTime.spec.ts b/test/e2e/SkipAllAfterTime.spec.ts index 1a663b1631d..4da78591cc4 100644 --- a/test/e2e/SkipAllAfterTime.spec.ts +++ b/test/e2e/SkipAllAfterTime.spec.ts @@ -21,7 +21,7 @@ describe(`SkipAllAfterTime (seed: ${seed})`, () => { it('should interrupt as soon as delay expires and mark run as success (no failure before)', () => { let numRuns = 0; const out = fc.check( - fc.property(fc.integer(), x => { + fc.property(fc.integer(), _n => { ++numRuns; return true; }), @@ -37,7 +37,7 @@ describe(`SkipAllAfterTime (seed: ${seed})`, () => { it('should interrupt as soon as delay expires and mark run as failure if asked to', () => { let numRuns = 0; const out = fc.check( - fc.property(fc.integer(), x => { + fc.property(fc.integer(), _n => { ++numRuns; return true; }), @@ -53,7 +53,7 @@ describe(`SkipAllAfterTime (seed: ${seed})`, () => { it('should consider interrupt with higer priority than skip', () => { let numRuns = 0; const out = fc.check( - fc.property(fc.integer(), x => { + fc.property(fc.integer(), _n => { ++numRuns; return true; }), diff --git a/test/unit/check/arbitrary/ArrayArbitrary.spec.ts b/test/unit/check/arbitrary/ArrayArbitrary.spec.ts index 13970c71c9a..b061eafdf5b 100644 --- a/test/unit/check/arbitrary/ArrayArbitrary.spec.ts +++ b/test/unit/check/arbitrary/ArrayArbitrary.spec.ts @@ -16,7 +16,7 @@ class DummyArbitrary extends Arbitrary<{ key: number }> { constructor(public value: () => number) { super(); } - generate(mrng: Random): Shrinkable<{ key: number }> { + generate(_mrng: Random): Shrinkable<{ key: number }> { return new Shrinkable({ key: this.value() }); } } diff --git a/test/unit/check/arbitrary/DateArbitrary.utest.spec.ts b/test/unit/check/arbitrary/DateArbitrary.utest.spec.ts index e3a00721065..1425746642f 100644 --- a/test/unit/check/arbitrary/DateArbitrary.utest.spec.ts +++ b/test/unit/check/arbitrary/DateArbitrary.utest.spec.ts @@ -17,7 +17,7 @@ describe('DateArbitrary', () => { it('Should be able to build the minimal valid date', () => { // Arrange const { integer } = mocked(IntegerArbitraryMock); - integer.mockImplementationOnce((a, b) => arbitraryFor([{ value: a }])); + integer.mockImplementationOnce((a, _b) => arbitraryFor([{ value: a }])); // Act const arb = date(); diff --git a/test/unit/check/arbitrary/LetRecArbitrary.spec.ts b/test/unit/check/arbitrary/LetRecArbitrary.spec.ts index 0963a3159b7..57fc9d57bd9 100644 --- a/test/unit/check/arbitrary/LetRecArbitrary.spec.ts +++ b/test/unit/check/arbitrary/LetRecArbitrary.spec.ts @@ -11,7 +11,7 @@ describe('LetRecArbitrary', () => { const expectedArb1 = buildArbitrary(jest.fn()); const expectedArb2 = buildArbitrary(jest.fn()); - const { arb1, arb2 } = letrec(tie => ({ + const { arb1, arb2 } = letrec(_tie => ({ arb1: expectedArb1, arb2: expectedArb2 })); @@ -20,7 +20,7 @@ describe('LetRecArbitrary', () => { expect(arb2).toBe(expectedArb2); }); it('Should not produce LazyArbitrary for no-tie constructs', () => { - const { arb } = letrec(tie => ({ + const { arb } = letrec(_tie => ({ arb: buildArbitrary(jest.fn()) })); expect(arb).not.toBeInstanceOf(LazyArbitrary); diff --git a/test/unit/check/arbitrary/MixedCaseArbitrary.utest.spec.ts b/test/unit/check/arbitrary/MixedCaseArbitrary.utest.spec.ts index 879af41b98c..c2301cdc180 100644 --- a/test/unit/check/arbitrary/MixedCaseArbitrary.utest.spec.ts +++ b/test/unit/check/arbitrary/MixedCaseArbitrary.utest.spec.ts @@ -26,7 +26,7 @@ describe('MixedCaseArbitrary', () => { it('should not toggle any character if flags are null', () => { // Arrange const { bigUintN } = mocked(BigIntArbitraryMock); - bigUintN.mockImplementationOnce(n => arbitraryFor([{ value: BigInt(0) }])); + bigUintN.mockImplementationOnce(_n => arbitraryFor([{ value: BigInt(0) }])); const stringArb = arbitraryFor([{ value: 'azerty' }]); // Act @@ -40,7 +40,7 @@ describe('MixedCaseArbitrary', () => { it('should toggle characters according to flags', () => { // Arrange const { bigUintN } = mocked(BigIntArbitraryMock); - bigUintN.mockImplementationOnce(n => arbitraryFor([{ value: BigInt(9) /* 001001 */ }])); + bigUintN.mockImplementationOnce(_n => arbitraryFor([{ value: BigInt(9) /* 001001 */ }])); const stringArb = arbitraryFor([{ value: 'azerty' }]); // Act @@ -54,7 +54,7 @@ describe('MixedCaseArbitrary', () => { it('should toggle both lower and upper characters', () => { // Arrange const { bigUintN } = mocked(BigIntArbitraryMock); - bigUintN.mockImplementationOnce(n => arbitraryFor([{ value: BigInt(9) /* 001001 */ }])); + bigUintN.mockImplementationOnce(_n => arbitraryFor([{ value: BigInt(9) /* 001001 */ }])); const stringArb = arbitraryFor([{ value: 'azERty' }]); // Act @@ -68,7 +68,7 @@ describe('MixedCaseArbitrary', () => { it('should not try to toggle characters that do not have lower/upper versions', () => { // Arrange const { bigUintN } = mocked(BigIntArbitraryMock); - bigUintN.mockImplementationOnce(n => arbitraryFor([{ value: BigInt(0) }])); + bigUintN.mockImplementationOnce(_n => arbitraryFor([{ value: BigInt(0) }])); const stringArb = arbitraryFor([{ value: 'az01ty' }]); // 01 upper version is the same // Act @@ -149,7 +149,7 @@ describe('MixedCaseArbitrary', () => { it('should use toggle function when provided to check what can be toggled or not', () => { // Arrange const { bigUintN } = mocked(BigIntArbitraryMock); - bigUintN.mockImplementationOnce(n => arbitraryFor([{ value: BigInt(63) /* 111111 */ }])); + bigUintN.mockImplementationOnce(_n => arbitraryFor([{ value: BigInt(63) /* 111111 */ }])); const stringArb = arbitraryFor([{ value: 'azerty' }]); const customToggle = jest.fn(); customToggle.mockImplementation((c: string) => { diff --git a/test/unit/check/arbitrary/ObjectArbitrary.spec.ts b/test/unit/check/arbitrary/ObjectArbitrary.spec.ts index d842093dc81..224da7fefa3 100644 --- a/test/unit/check/arbitrary/ObjectArbitrary.spec.ts +++ b/test/unit/check/arbitrary/ObjectArbitrary.spec.ts @@ -130,7 +130,7 @@ describe('ObjectArbitrary', () => { const mrng = new Random(prand.xorshift128plus(seed)); let shrinkable = anything().generate(mrng); const originalValue = shrinkable.value; - while (shrinkable.shrink().has(v => true)[0]) { + while (shrinkable.shrink().has(_ => true)[0]) { shrinkable = shrinkable.shrink().next().value; } // only check one shrink path assertShrinkedValue(originalValue, shrinkable.value); @@ -282,7 +282,7 @@ describe('ObjectArbitrary', () => { const mrng = new Random(prand.xorshift128plus(seed)); let shrinkable = json().generate(mrng); const originalValue = shrinkable.value; - while (shrinkable.shrink().has(v => true)[0]) { + while (shrinkable.shrink().has(_ => true)[0]) { shrinkable = shrinkable.shrink().next().value; } // only check one shrink path expect(typeof shrinkable.value).toEqual('string'); @@ -312,7 +312,7 @@ describe('ObjectArbitrary', () => { const mrng = new Random(prand.xorshift128plus(seed)); let shrinkable = unicodeJson().generate(mrng); const originalValue = shrinkable.value; - while (shrinkable.shrink().has(v => true)[0]) { + while (shrinkable.shrink().has(_ => true)[0]) { shrinkable = shrinkable.shrink().next().value; } // only check one shrink path expect(typeof shrinkable.value).toEqual('string'); @@ -398,7 +398,7 @@ describe('ObjectArbitrary', () => { fc.property(fc.integer(), seed => { const mrng = new Random(prand.xorshift128plus(seed)); let shrinkable = object().generate(mrng); - while (shrinkable.shrink().has(v => true)[0]) { + while (shrinkable.shrink().has(_ => true)[0]) { shrinkable = shrinkable.shrink().next().value; } // only check one shrink path return typeof shrinkable.value === 'object' && Object.keys(shrinkable.value).length === 0; diff --git a/test/unit/check/arbitrary/OneOfArbitrary.spec.ts b/test/unit/check/arbitrary/OneOfArbitrary.spec.ts index 7e55641f874..a6d6d62504a 100644 --- a/test/unit/check/arbitrary/OneOfArbitrary.spec.ts +++ b/test/unit/check/arbitrary/OneOfArbitrary.spec.ts @@ -16,7 +16,7 @@ class CustomArbitrary extends Arbitrary { constructor(readonly value: number) { super(); } - generate(mrng: Random): Shrinkable { + generate(_mrng: Random): Shrinkable { function* g(v: number) { yield new Shrinkable(v - 42); } diff --git a/test/unit/check/arbitrary/OptionArbitrary.spec.ts b/test/unit/check/arbitrary/OptionArbitrary.spec.ts index 14a19f91e07..02014763fd3 100644 --- a/test/unit/check/arbitrary/OptionArbitrary.spec.ts +++ b/test/unit/check/arbitrary/OptionArbitrary.spec.ts @@ -28,7 +28,7 @@ describe('OptionArbitrary', () => { fc.property(fc.integer(), fc.integer(), (seed, start) => { const mrng = stubRng.mutable.fastincrease(seed); let shrinkable = option(stubArb.withShrink(start)).generate(mrng); - while (shrinkable.shrink().has(v => true)[0]) { + while (shrinkable.shrink().has(_ => true)[0]) { shrinkable = shrinkable.shrink().next().value; } // only check one shrink path return shrinkable.value === null; diff --git a/test/unit/check/arbitrary/UuidArbitrary.utest.spec.ts b/test/unit/check/arbitrary/UuidArbitrary.utest.spec.ts index 0f864276068..f5e72400ece 100644 --- a/test/unit/check/arbitrary/UuidArbitrary.utest.spec.ts +++ b/test/unit/check/arbitrary/UuidArbitrary.utest.spec.ts @@ -20,7 +20,7 @@ describe('UuidArbitrary', () => { const { nat, integer } = mocked(IntegerArbitraryMock); const { tuple } = mocked(TupleArbitraryMock); nat.mockImplementation(() => arbitraryFor([{ value: 0 }, { value: 0 }, { value: 0 }])); - integer.mockImplementation((a, b) => arbitraryFor([{ value: a }])); + integer.mockImplementation((a, _b) => arbitraryFor([{ value: a }])); tuple.mockImplementation((...arbs) => arbitraryFor([{ value: arbs.map(a => a.generate(mrng()).value_) as any }])); // Act @@ -57,7 +57,7 @@ describe('UuidArbitrary', () => { const { nat, integer } = mocked(IntegerArbitraryMock); const { tuple } = mocked(TupleArbitraryMock); nat.mockImplementation(() => arbitraryFor([{ value: 0 }, { value: 0 }])); - integer.mockImplementation((a, b) => arbitraryFor([{ value: a }])); + integer.mockImplementation((a, _b) => arbitraryFor([{ value: a }])); tuple.mockImplementation((...arbs) => arbitraryFor([{ value: arbs.map(a => a.generate(mrng()).value_) as any }])); // Act diff --git a/test/unit/check/arbitrary/definition/Arbitrary.spec.ts b/test/unit/check/arbitrary/definition/Arbitrary.spec.ts index c0bb7c22c90..9eac64b016d 100644 --- a/test/unit/check/arbitrary/definition/Arbitrary.spec.ts +++ b/test/unit/check/arbitrary/definition/Arbitrary.spec.ts @@ -36,16 +36,16 @@ class FakeNoBiasArbitrary extends Arbitrary { generate(mrng: Random): Shrinkable { return new ForwardArbitrary().generate(mrng); } - withBias(freq: number) { + withBias(_freq: number) { return new ForwardArbitrary(); } } class FakeTwoValuesBiasArbitrary extends Arbitrary { - generate(mrng: Random): Shrinkable { + generate(_mrng: Random): Shrinkable { return new Shrinkable(44); } - withBias(freq: number) { + withBias(_freq: number) { return new (class extends Arbitrary { generate(mrng: Random): Shrinkable { return mrng.nextInt(1, 2) === 1 ? new Shrinkable(42) : new Shrinkable(43); @@ -175,7 +175,7 @@ describe('Arbitrary', () => { fc.assert( fc.property(fc.integer(), (seed: number) => { const mrng = stubRng.mutable.fastincrease(seed); - const fmapper = (v: number) => new ForwardArbitrary(); + const fmapper = (_v: number) => new ForwardArbitrary(); const arb = constant(0).chain(fmapper); const biasedArb = arb.withBias(1); // 100% of bias - not recommended outside of tests const g = biasedArb.generate(mrng).value; diff --git a/test/unit/check/arbitrary/definition/ArbitraryWithShrink.spec.ts b/test/unit/check/arbitrary/definition/ArbitraryWithShrink.spec.ts index 869a539bd99..810aba0017b 100644 --- a/test/unit/check/arbitrary/definition/ArbitraryWithShrink.spec.ts +++ b/test/unit/check/arbitrary/definition/ArbitraryWithShrink.spec.ts @@ -8,7 +8,7 @@ import { Stream, stream } from '../../../../../src/stream/Stream'; describe('ArbitraryWithShrink', () => { const arbWithShrink = new (class extends ArbitraryWithShrink { - generate(mrng: Random): Shrinkable { + generate(_mrng: Random): Shrinkable { throw new Error('Method not implemented.'); } shrink(value: number, shrunkOnce?: boolean): Stream { diff --git a/test/unit/check/arbitrary/generic/GenericArbitraryHelper.ts b/test/unit/check/arbitrary/generic/GenericArbitraryHelper.ts index 2b053693507..36ae6c1d11e 100644 --- a/test/unit/check/arbitrary/generic/GenericArbitraryHelper.ts +++ b/test/unit/check/arbitrary/generic/GenericArbitraryHelper.ts @@ -134,7 +134,7 @@ export const isValidArbitrary = function( const biasedArbitraryBuilder = ([biasedFactor, u]: [(number | null), U]) => { return biasedFactor != null ? arbitraryBuilder(u).withBias(biasedFactor) : arbitraryBuilder(u); }; - const biasedIsValidValue = (g: T, [biasedFactor, u]: [(number | null), U]) => { + const biasedIsValidValue = (g: T, [_biasedFactor, u]: [(number | null), U]) => { return settings.isValidValue(g, u); }; diff --git a/test/unit/check/model/ModelRunner.spec.ts b/test/unit/check/model/ModelRunner.spec.ts index 1691aa6fe6c..75b739813ba 100644 --- a/test/unit/check/model/ModelRunner.spec.ts +++ b/test/unit/check/model/ModelRunner.spec.ts @@ -74,7 +74,7 @@ describe('ModelRunner', () => { calledBeforeDataReady = calledBeforeDataReady || !setupDataReady; return true; }; - run = async (m: {}, r: {}) => { + run = async (_m: {}, _r: {}) => { calledBeforeDataReady = calledBeforeDataReady || !setupDataReady; }; })(); diff --git a/test/unit/check/model/commands/CommandWrapper.spec.ts b/test/unit/check/model/commands/CommandWrapper.spec.ts index 85ae003552a..f1f0eb69779 100644 --- a/test/unit/check/model/commands/CommandWrapper.spec.ts +++ b/test/unit/check/model/commands/CommandWrapper.spec.ts @@ -9,8 +9,8 @@ type Real = {}; describe('CommandWrapper', () => { it('Should show name of the command if it has not run', () => { const cmd = new (class implements Command { - check = (m: Readonly) => true; - run = (m: Model, r: Real) => {}; + check = (_m: Readonly) => true; + run = (_m: Model, _r: Real) => {}; toString = () => 'sync command'; })(); const wrapper = new CommandWrapper(cmd); @@ -18,8 +18,8 @@ describe('CommandWrapper', () => { }); it('Should show name of the command if it has run', () => { const cmd = new (class implements Command { - check = (m: Readonly) => true; - run = (m: Model, r: Real) => {}; + check = (_m: Readonly) => true; + run = (_m: Model, _r: Real) => {}; toString = () => 'sync command'; })(); const wrapper = new CommandWrapper(cmd); @@ -28,8 +28,8 @@ describe('CommandWrapper', () => { }); it('Should reset run flag of clone', () => { const cmd = new (class implements Command { - check = (m: Readonly) => true; - run = (m: Model, r: Real) => {}; + check = (_m: Readonly) => true; + run = (_m: Model, _r: Real) => {}; toString = () => 'sync command'; })(); const wrapper = new CommandWrapper(cmd); @@ -40,8 +40,8 @@ describe('CommandWrapper', () => { }); it('Should consider a run on success', () => { const cmd = new (class implements Command { - check = (m: Readonly) => true; - run = (m: Model, r: Real) => {}; + check = (_m: Readonly) => true; + run = (_m: Model, _r: Real) => {}; toString = () => 'sync command'; })(); const wrapper = new CommandWrapper(cmd); @@ -51,8 +51,8 @@ describe('CommandWrapper', () => { }); it('Should consider a run on failure', () => { const cmd = new (class implements Command { - check = (m: Readonly) => true; - run = (m: Model, r: Real) => { + check = (_m: Readonly) => true; + run = (_m: Model, _r: Real) => { throw 'failure message'; }; toString = () => 'sync command'; @@ -64,8 +64,8 @@ describe('CommandWrapper', () => { }); it('Should consider a run on asynchronous success', async () => { const cmd = new (class implements AsyncCommand { - check = (m: Readonly) => true; - run = async (m: Model, r: Real) => {}; + check = (_m: Readonly) => true; + run = async (_m: Model, _r: Real) => {}; toString = () => 'async command'; })(); const wrapper = new CommandWrapper(cmd); @@ -75,8 +75,8 @@ describe('CommandWrapper', () => { }); it('Should consider a run on asynchronous failure', async () => { const cmd = new (class implements AsyncCommand { - check = (m: Readonly) => true; - run = async (m: Model, r: Real) => { + check = (_m: Readonly) => true; + run = async (_m: Model, _r: Real) => { throw 'failure message'; }; toString = () => 'async command'; diff --git a/test/unit/check/model/commands/CommandsIterable.spec.ts b/test/unit/check/model/commands/CommandsIterable.spec.ts index 6631dcbe683..c5b4e677dac 100644 --- a/test/unit/check/model/commands/CommandsIterable.spec.ts +++ b/test/unit/check/model/commands/CommandsIterable.spec.ts @@ -11,8 +11,8 @@ type Real = {}; const buildAlreadyRanCommands = (runFlags: boolean[]) => { return runFlags.map((hasRun, idx) => { const cmd = new (class implements Command { - check = (m: Readonly) => true; - run = (m: Model, r: Real) => {}; + check = (_m: Readonly) => true; + run = (_m: Model, _r: Real) => {}; toString = () => String(idx); })(); const wrapper = new CommandWrapper(cmd); diff --git a/test/unit/check/property/AsyncProperty.spec.ts b/test/unit/check/property/AsyncProperty.spec.ts index ac7de464bb0..285741fcc66 100644 --- a/test/unit/check/property/AsyncProperty.spec.ts +++ b/test/unit/check/property/AsyncProperty.spec.ts @@ -9,19 +9,19 @@ import * as stubRng from '../../stubs/generators'; describe('AsyncProperty', () => { it('Should fail if predicate fails', async () => { - const p = asyncProperty(stubArb.single(8), async (arg: number) => { + const p = asyncProperty(stubArb.single(8), async (_arg: number) => { return false; }); expect(await p.run(p.generate(stubRng.mutable.nocall()).value)).not.toBe(null); // property fails }); it('Should fail if predicate throws', async () => { - const p = asyncProperty(stubArb.single(8), async (arg: number) => { + const p = asyncProperty(stubArb.single(8), async (_arg: number) => { throw 'predicate throws'; }); expect(await p.run(p.generate(stubRng.mutable.nocall()).value)).toEqual('predicate throws'); }); it('Should fail if predicate throws an Error', async () => { - const p = asyncProperty(stubArb.single(8), async (arg: number) => { + const p = asyncProperty(stubArb.single(8), async (_arg: number) => { throw new Error('predicate throws'); }); const out = await p.run(p.generate(stubRng.mutable.nocall()).value); @@ -30,7 +30,7 @@ describe('AsyncProperty', () => { }); it('Should forward failure of runs with failing precondition', async () => { let doNotResetThisValue = false; - const p = asyncProperty(stubArb.single(8), async (arg: number) => { + const p = asyncProperty(stubArb.single(8), async (_arg: number) => { pre(false); doNotResetThisValue = true; return false; @@ -40,22 +40,22 @@ describe('AsyncProperty', () => { expect(doNotResetThisValue).toBe(false); // does not run code after the failing precondition }); it('Should succeed if predicate is true', async () => { - const p = asyncProperty(stubArb.single(8), async (arg: number) => { + const p = asyncProperty(stubArb.single(8), async (_arg: number) => { return true; }); expect(await p.run(p.generate(stubRng.mutable.nocall()).value)).toBe(null); }); it('Should succeed if predicate does not return anything', async () => { - const p = asyncProperty(stubArb.single(8), async (arg: number) => {}); + const p = asyncProperty(stubArb.single(8), async (_arg: number) => {}); expect(await p.run(p.generate(stubRng.mutable.nocall()).value)).toBe(null); }); it('Should wait until completion of the check to follow', async () => { - const delay = () => new Promise((resolve, reject) => setTimeout(resolve, 0)); + const delay = () => new Promise(resolve => setTimeout(resolve, 0)); let runnerHasCompleted = false; let resolvePromise: (t: boolean) => void = (null as any) as ((t: boolean) => void); - const p = asyncProperty(stubArb.single(8), async (arg: number) => { - return await new Promise(function(resolve, reject) { + const p = asyncProperty(stubArb.single(8), async (_arg: number) => { + return await new Promise(function(resolve) { resolvePromise = resolve; }); }); @@ -113,7 +113,7 @@ describe('AsyncProperty', () => { }); it('Should always execute beforeEach before the test', async () => { const prob = { beforeEachCalled: false }; - const p = asyncProperty(stubArb.single(8), async (arg: number) => { + const p = asyncProperty(stubArb.single(8), async (_arg: number) => { const beforeEachCalled = prob.beforeEachCalled; prob.beforeEachCalled = false; return beforeEachCalled; @@ -124,7 +124,7 @@ describe('AsyncProperty', () => { }); it('Should execute afterEach after the test on success', async () => { const callOrder: string[] = []; - const p = asyncProperty(stubArb.single(8), async (arg: number) => { + const p = asyncProperty(stubArb.single(8), async (_arg: number) => { callOrder.push('test'); return true; }).afterEach(async () => { @@ -135,7 +135,7 @@ describe('AsyncProperty', () => { }); it('Should execute afterEach after the test on failure', async () => { const callOrder: string[] = []; - const p = asyncProperty(stubArb.single(8), async (arg: number) => { + const p = asyncProperty(stubArb.single(8), async (_arg: number) => { callOrder.push('test'); return false; }).afterEach(async () => { @@ -146,7 +146,7 @@ describe('AsyncProperty', () => { }); it('Should execute afterEach after the test on uncaught exception', async () => { const callOrder: string[] = []; - const p = asyncProperty(stubArb.single(8), async (arg: number) => { + const p = asyncProperty(stubArb.single(8), async (_arg: number) => { callOrder.push('test'); throw new Error('uncaught'); }).afterEach(async () => { diff --git a/test/unit/check/property/Property.spec.ts b/test/unit/check/property/Property.spec.ts index 60efd276c54..845bf0cbfd7 100644 --- a/test/unit/check/property/Property.spec.ts +++ b/test/unit/check/property/Property.spec.ts @@ -9,20 +9,20 @@ import * as stubRng from '../../stubs/generators'; describe('Property', () => { it('Should fail if predicate fails', () => { - const p = property(stubArb.single(8), (arg: number) => { + const p = property(stubArb.single(8), (_arg: number) => { return false; }); expect(p.run(p.generate(stubRng.mutable.nocall()).value)).not.toBe(null); // property fails }); it('Should fail if predicate throws', () => { - const p = property(stubArb.single(8), (arg: number) => { + const p = property(stubArb.single(8), (_arg: number) => { throw 'predicate throws'; }); const out = p.run(p.generate(stubRng.mutable.nocall()).value); expect(out).toEqual('predicate throws'); }); it('Should fail if predicate throws an Error', () => { - const p = property(stubArb.single(8), (arg: number) => { + const p = property(stubArb.single(8), (_arg: number) => { throw new Error('predicate throws'); }); const out = p.run(p.generate(stubRng.mutable.nocall()).value); @@ -31,7 +31,7 @@ describe('Property', () => { }); it('Should forward failure of runs with failing precondition', async () => { let doNotResetThisValue = false; - const p = property(stubArb.single(8), (arg: number) => { + const p = property(stubArb.single(8), (_arg: number) => { pre(false); doNotResetThisValue = true; return false; @@ -41,13 +41,13 @@ describe('Property', () => { expect(doNotResetThisValue).toBe(false); // does not run code after the failing precondition }); it('Should succeed if predicate is true', () => { - const p = property(stubArb.single(8), (arg: number) => { + const p = property(stubArb.single(8), (_arg: number) => { return true; }); expect(p.run(p.generate(stubRng.mutable.nocall()).value)).toBe(null); }); it('Should succeed if predicate does not return anything', () => { - const p = property(stubArb.single(8), (arg: number) => {}); + const p = property(stubArb.single(8), (_arg: number) => {}); expect(p.run(p.generate(stubRng.mutable.nocall()).value)).toBe(null); }); it('Should call and forward arbitraries one time', () => { @@ -57,7 +57,7 @@ describe('Property', () => { stubArb.SingleUseArbitrary, stubArb.SingleUseArbitrary ] = [stubArb.single(3), stubArb.single('hello'), stubArb.single('world')]; - const p = property(arbs[0], arbs[1], arbs[2], (arg1: number, arb2: string, arg3: string) => { + const p = property(arbs[0], arbs[1], arbs[2], (arg1: number, _arb2: string, _arg3: string) => { if (oneCallToPredicate) { throw 'Predicate has already been evaluated once'; } @@ -114,7 +114,7 @@ describe('Property', () => { }); it('Should always execute beforeEach before the test', () => { const prob = { beforeEachCalled: false }; - const p = property(stubArb.single(8), (arg: number) => { + const p = property(stubArb.single(8), (_arg: number) => { const beforeEachCalled = prob.beforeEachCalled; prob.beforeEachCalled = false; return beforeEachCalled; @@ -123,7 +123,7 @@ describe('Property', () => { }); it('Should execute afterEach after the test on success', () => { const callOrder: string[] = []; - const p = property(stubArb.single(8), (arg: number) => { + const p = property(stubArb.single(8), (_arg: number) => { callOrder.push('test'); return true; }).afterEach(() => callOrder.push('afterEach')); @@ -132,7 +132,7 @@ describe('Property', () => { }); it('Should execute afterEach after the test on failure', () => { const callOrder: string[] = []; - const p = property(stubArb.single(8), (arg: number) => { + const p = property(stubArb.single(8), (_arg: number) => { callOrder.push('test'); return false; }).afterEach(() => callOrder.push('afterEach')); @@ -141,7 +141,7 @@ describe('Property', () => { }); it('Should execute afterEach after the test on uncaught exception', () => { const callOrder: string[] = []; - const p = property(stubArb.single(8), (arg: number) => { + const p = property(stubArb.single(8), (_arg: number) => { callOrder.push('test'); throw new Error('uncaught'); }).afterEach(() => callOrder.push('afterEach')); diff --git a/test/unit/check/property/TimeoutProperty.utest.spec.ts b/test/unit/check/property/TimeoutProperty.utest.spec.ts index 821e7085968..c9abc1b5f56 100644 --- a/test/unit/check/property/TimeoutProperty.utest.spec.ts +++ b/test/unit/check/property/TimeoutProperty.utest.spec.ts @@ -60,7 +60,7 @@ describe('TimeoutProperty', () => { isAsync: () => true, generate: jest.fn(), run: jest.fn().mockReturnValueOnce( - new Promise(function(resolve, reject) { + new Promise(function(resolve) { setTimeout(() => resolve(null), 10); }) ) @@ -81,7 +81,7 @@ describe('TimeoutProperty', () => { isAsync: () => true, generate: jest.fn(), run: jest.fn().mockReturnValueOnce( - new Promise(function(resolve, reject) { + new Promise(function(resolve) { // underlying property is not supposed to throw (reject) setTimeout(() => resolve('plop'), 10); }) @@ -137,7 +137,7 @@ describe('TimeoutProperty', () => { isAsync: () => true, generate: jest.fn(), run: jest.fn().mockReturnValueOnce( - new Promise(function(resolve, reject) { + new Promise(function(resolve) { setTimeout(() => resolve(null), 100); }) ) @@ -157,7 +157,7 @@ describe('TimeoutProperty', () => { const p: IRawProperty<{}> = { isAsync: () => true, generate: jest.fn(), - run: jest.fn().mockReturnValueOnce(new Promise(function(resolve, reject) {})) + run: jest.fn().mockReturnValueOnce(new Promise(() => {})) }; // Act diff --git a/test/unit/check/runner/Runner.spec.ts b/test/unit/check/runner/Runner.spec.ts index 740879cdbef..9b519ce13ad 100644 --- a/test/unit/check/runner/Runner.spec.ts +++ b/test/unit/check/runner/Runner.spec.ts @@ -173,7 +173,7 @@ describe('Runner', () => { throw 'Not implemented'; }) as Shrinkable<[number]>; }, - run: (value: [number]) => { + run: (_value: [number]) => { ++numCallsRun; return null; } @@ -194,7 +194,7 @@ describe('Runner', () => { ++numCallsGenerate; return new Shrinkable([0]) as Shrinkable<[number]>; }, - run: (value: [number]) => { + run: (_value: [number]) => { return ++numCallsRun < num ? null : 'error'; } }; @@ -218,7 +218,7 @@ describe('Runner', () => { ++numCallsGenerate; return new Shrinkable([0]) as Shrinkable<[number]>; }, - run: (value: [number]) => { + run: (_value: [number]) => { ++numCallsRun; return null; } @@ -262,7 +262,7 @@ describe('Runner', () => { throw 'Not implemented'; }) as Shrinkable<[number]>; }, - run: (value: [number]) => { + run: (_value: [number]) => { return 'failure'; } }; @@ -332,8 +332,8 @@ describe('Runner', () => { let remainingBeforeFailure = failurePoints[idx]; const p: IRawProperty<[number]> = { isAsync: () => false, - generate: (rng: Random) => deepShrinkable(failurePoints.length - 1), - run: (value: [number]) => { + generate: (_mrng: Random) => deepShrinkable(failurePoints.length - 1), + run: (_value: [number]) => { if (--remainingBeforeFailure >= 0) return null; remainingBeforeFailure = failurePoints[++idx]; return 'failure'; @@ -351,7 +351,7 @@ describe('Runner', () => { it('Should wait on async properties to complete', async () => fc.assert( fc.asyncProperty(fc.integer(1, 100), fc.integer(), async (num, seed) => { - const delay = () => new Promise((resolve, reject) => setTimeout(resolve, 0)); + const delay = () => new Promise(resolve => setTimeout(resolve, 0)); let runnerHasCompleted = false; const waitingResolve: (() => void)[] = []; @@ -367,8 +367,8 @@ describe('Runner', () => { }; return new Shrinkable([1], () => new Stream(g())) as Shrinkable<[number]>; }, - run: async (value: [number]) => { - await new Promise((resolve, reject) => { + run: async (_value: [number]) => { + await new Promise(resolve => { waitingResolve.push(resolve); }); return ++numCallsRun < num ? null : 'error'; @@ -402,37 +402,37 @@ describe('Runner', () => { const p: IRawProperty<[number]> = { isAsync: () => true, generate: () => new Shrinkable([1]) as Shrinkable<[number]>, - run: async (value: [number]) => null + run: async (_value: [number]) => null }; const out = await (check(p) as Promise>); expect(out.failed).toBe(false); }); it('Should not timeout if timeout not reached', async () => { - const wait = (timeMs: number) => new Promise((resolve, reject) => setTimeout(resolve, timeMs)); + const wait = (timeMs: number) => new Promise(resolve => setTimeout(resolve, timeMs)); const p: IRawProperty<[number]> = { isAsync: () => true, generate: () => new Shrinkable([1]) as Shrinkable<[number]>, - run: async (value: [number]) => await wait(0) + run: async (_value: [number]) => await wait(0) }; const out = await (check(p, { timeout: 100 }) as Promise>); expect(out.failed).toBe(false); }); it('Should timeout if it reached the timeout', async () => { - const wait = (timeMs: number) => new Promise((resolve, reject) => setTimeout(resolve, timeMs)); + const wait = (timeMs: number) => new Promise(resolve => setTimeout(resolve, timeMs)); const p: IRawProperty<[number]> = { isAsync: () => true, generate: () => new Shrinkable([1]) as Shrinkable<[number]>, - run: async (value: [number]) => await wait(100) + run: async (_value: [number]) => await wait(100) }; const out = await (check(p, { timeout: 0 }) as Promise>); expect(out.failed).toBe(true); }); it('Should timeout if task never ends', async () => { - const neverEnds = () => new Promise((resolve, reject) => {}); + const neverEnds = () => new Promise(() => {}); const p: IRawProperty<[number]> = { isAsync: () => true, generate: () => new Shrinkable([1]) as Shrinkable<[number]>, - run: async (value: [number]) => await neverEnds() + run: async (_value: [number]) => await neverEnds() }; const out = await (check(p, { timeout: 0 }) as Promise>); expect(out.failed).toBe(true); @@ -444,17 +444,17 @@ describe('Runner', () => { const failingProperty: IRawProperty<[any, any]> = { isAsync: () => false, generate: () => new Shrinkable([v1, v2]) as Shrinkable<[any, any]>, - run: (v: [any, any]) => 'error in failingProperty' + run: (_v: [any, any]) => 'error in failingProperty' }; const failingComplexProperty: IRawProperty<[any, any, any]> = { isAsync: () => false, generate: () => new Shrinkable([[v1, v2], v2, v1]) as Shrinkable<[any, any, any]>, - run: (v: [any, any, any]) => 'error in failingComplexProperty' + run: (_v: [any, any, any]) => 'error in failingComplexProperty' }; const successProperty: IRawProperty<[any, any]> = { isAsync: () => false, generate: () => new Shrinkable([v1, v2]) as Shrinkable<[any, any]>, - run: (v: [any, any]) => null + run: (_v: [any, any]) => null }; it('Should throw if property is null', () => { diff --git a/test/unit/check/runner/Sampler.spec.ts b/test/unit/check/runner/Sampler.spec.ts index 8d7a2943ede..e37824a4e8c 100644 --- a/test/unit/check/runner/Sampler.spec.ts +++ b/test/unit/check/runner/Sampler.spec.ts @@ -183,7 +183,7 @@ describe('Sampler', () => { fc.property(fc.nat(MAX_NUM_RUNS), fc.integer(), (num, start) => { const classify = (g: number) => g.toString(); const arb = stubArb.counter(start); - statistics(arb, classify, { numRuns: num, logger: (v: string) => {} }); + statistics(arb, classify, { numRuns: num, logger: (_v: string) => {} }); expect(arb.generatedValues).toHaveLength(num); // only call the arbitrary once per asked value }) )); diff --git a/test/unit/stream/Stream.spec.ts b/test/unit/stream/Stream.spec.ts index f39f9f3ebef..e2c0cd67ae2 100644 --- a/test/unit/stream/Stream.spec.ts +++ b/test/unit/stream/Stream.spec.ts @@ -101,14 +101,14 @@ describe('Stream', () => { function* g() { yield* [-4, -2, -3, 1, -8, 7]; } - const s = stream(g()).dropWhile(v => true); + const s = stream(g()).dropWhile(_ => true); expect([...s]).toEqual([]); }); it('Should drop nothing', () => { function* g() { yield* [-4, -2, -3, 1, -8, 7]; } - const s = stream(g()).dropWhile(v => false); + const s = stream(g()).dropWhile(_ => false); expect([...s]).toEqual([-4, -2, -3, 1, -8, 7]); }); }); @@ -133,14 +133,14 @@ describe('Stream', () => { function* g() { yield* [-4, -2, -3, 1, -8, 7]; } - const s = stream(g()).takeWhile(v => true); + const s = stream(g()).takeWhile(_ => true); expect([...s]).toEqual([-4, -2, -3, 1, -8, 7]); }); it('Should take nothing', () => { function* g() { yield* [-4, -2, -3, 1, -8, 7]; } - const s = stream(g()).takeWhile(v => false); + const s = stream(g()).takeWhile(_ => false); expect([...s]).toEqual([]); }); }); diff --git a/test/unit/stubs/arbitraries.ts b/test/unit/stubs/arbitraries.ts index 65a5458d167..31bb506e7d8 100644 --- a/test/unit/stubs/arbitraries.ts +++ b/test/unit/stubs/arbitraries.ts @@ -14,7 +14,7 @@ class CounterArbitrary extends Arbitrary { constructor(private value: number) { super(); } - generate(rng: Random): Shrinkable { + generate(_mrng: Random): Shrinkable { const last = this.value++ | 0; // keep it in integer range this.generatedValues.push(last); return new Shrinkable(last); @@ -44,10 +44,10 @@ class ForwardArrayArbitrary extends Arbitrary { constructor(readonly num: number) { super(); } - generate(rng: Random): Shrinkable { + generate(mrng: Random): Shrinkable { const out = []; for (let idx = 0; idx !== this.num; ++idx) { - out.push(rng.nextInt()); + out.push(mrng.nextInt()); } return new Shrinkable(out); } @@ -64,7 +64,7 @@ class SingleUseArbitrary extends Arbitrary { constructor(public id: T) { super(); } - generate(mrng: Random) { + generate(_mrng: Random) { if (this.calledOnce) { throw 'Arbitrary has already been called once'; } @@ -94,7 +94,7 @@ class WithShrinkArbitrary extends Arbitrary { } return new Shrinkable(v, () => stream(g())); } - generate(rng: Random): Shrinkable { + generate(_mrng: Random): Shrinkable { const last = this.value++ | 0; // keep it in integer range return WithShrinkArbitrary.shrinkIt(last); }