From ede6ffac383a853c12b7a47cebbb031ba80627aa Mon Sep 17 00:00:00 2001 From: Shinigami Date: Wed, 3 May 2023 08:18:58 +0200 Subject: [PATCH] test: prepare test sources for strict mode (#2107) --- test/helpers.spec.ts | 3 +-- test/scripts/apidoc/signature.example.ts | 8 ++++---- test/support/seededRuns.ts | 2 +- vite.config.ts | 1 + 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/helpers.spec.ts b/test/helpers.spec.ts index 2dcb64aafb7..6cb397cbf6f 100644 --- a/test/helpers.spec.ts +++ b/test/helpers.spec.ts @@ -791,9 +791,8 @@ describe('helpers', () => { }); it('empty array returns empty array', () => { - const input = []; const length = faker.number.int({ min: 1, max: 6 }); - const unique = faker.helpers.uniqueArray(input, length); + const unique = faker.helpers.uniqueArray([], length); expect(unique).toHaveLength(0); }); diff --git a/test/scripts/apidoc/signature.example.ts b/test/scripts/apidoc/signature.example.ts index 97db90c88b6..6bb835c1819 100644 --- a/test/scripts/apidoc/signature.example.ts +++ b/test/scripts/apidoc/signature.example.ts @@ -94,7 +94,7 @@ export class SignatureTest { * @param b The string parameter. */ optionalStringParamMethod(b?: string): number { - return +b; + return b ? 0 : 1; } /** @@ -114,7 +114,7 @@ export class SignatureTest { * @param c The boolean parameter. */ multiParamMethod(a: number, b?: string, c: boolean = true): number { - return c ? a : +b; + return c ? a : b ? 0 : 1; } /** @@ -143,7 +143,7 @@ export class SignatureTest { excludes?: ReadonlyArray; } ): string { - return value + options.format; + return options?.format ?? value; } /** @@ -195,7 +195,7 @@ export class SignatureTest { */ e: LiteralUnion<'a' | 'b'>; }): number { - return options.c ? options.a : +options.b; + return options.a; } /** diff --git a/test/support/seededRuns.ts b/test/support/seededRuns.ts index 1cfc7fdc29b..5926fb5c4ed 100644 --- a/test/support/seededRuns.ts +++ b/test/support/seededRuns.ts @@ -34,7 +34,7 @@ type NoArgsMethodOf = MethodOf & { [Key in MethodOf unknown>]: ObjectType[Key] extends ( arg0: string | number | boolean | Record, - ...args + ...args: unknown[] ) => unknown ? Key : never; diff --git a/vite.config.ts b/vite.config.ts index cb3a67e3029..25ffc5897a0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -11,6 +11,7 @@ export default defineConfig({ setupFiles: ['test/setup.ts'], coverage: { all: true, + provider: 'c8', reporter: ['clover', 'cobertura', 'lcov', 'text'], include: ['src'], },