From d72331c5de39137a5028cbc9687471c25a3e7c09 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Thu, 21 Apr 2022 20:28:19 +0200 Subject: [PATCH] test: add more tests --- test/locale-imports.spec.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/test/locale-imports.spec.ts b/test/locale-imports.spec.ts index 4856c34aa7d..3fdbeed1d75 100644 --- a/test/locale-imports.spec.ts +++ b/test/locale-imports.spec.ts @@ -11,13 +11,29 @@ describe('locale imports', () => { expect(faker.locale).toBe(locale); }); - // Internal test to cover `src/locale/*.ts` - it(`should be possible to directly require('../locale/${locale}')`, () => { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const { faker } = require(`../locale/${locale}`); + it(`should be possible to directly import('@faker-js/faker/locale/${locale}')`, async () => { + const { faker } = await import(`../dist/esm/locale/${locale}`); expect(faker).toBeDefined(); expect(faker.locale).toBe(locale); }); + + describe('Internal tests to cover `src/locale/*.ts`', () => { + it(`should be possible to directly require('../locale/${locale}')`, () => { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const { faker } = require(`../locale/${locale}`); + + expect(faker).toBeDefined(); + expect(faker.locale).toBe(locale); + }); + + it(`should be possible to directly import('../src/locale/${locale}')`, async () => { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const { faker } = await import(`../src/locale/${locale}`); + + expect(faker).toBeDefined(); + expect(faker.locale).toBe(locale); + }); + }); } });