Skip to content

Commit d92bddd

Browse files
committed
chore: use vitest
1 parent 319553e commit d92bddd

16 files changed

+15356
-17973
lines changed

eslint.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,12 @@ export default [
6565
},
6666
{
6767
ignores: ["dist/", "docs/"]
68+
},
69+
{
70+
settings: {
71+
"import/ignore": [
72+
"vitest"
73+
],
74+
},
6875
}
6976
];

jest.config.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

locale-tests/all.test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { afterAll, beforeAll, describe, it, expect, vi } from 'vitest';
2+
13
import { formatNumber, parseNumber, formatDate, parseDate, firstDay, weekendRange, setData } from '../src/main';
24
import { LOCALES, NO_CURRENCY_LOCALE, clean } from './utils';
35

@@ -6,10 +8,12 @@ describe('generated-locales', () => {
68
const number = 5.55;
79
const numberString = '5.55';
810

9-
describe.each(LOCALES)('%s (all)', (locale) => {
10-
beforeAll(() => {
11-
const all = require(`./locales/${ locale }/all`).default;
12-
setData(all);
11+
describe.each(LOCALES)('%s (all)', async(locale) => {
12+
beforeAll(async () => {
13+
const all = await import(`./locales/${ locale }/all.js`);
14+
await vi.dynamicImportSettled();
15+
16+
setData(all.default);
1317
});
1418

1519
afterAll(() => {

locale-tests/calendar.test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
import { afterAll, beforeAll, describe, it, expect, vi } from 'vitest';
2+
13
import { formatDate, parseDate, firstDay, weekendRange, setData } from '../src/main';
24
import { LOCALES, clean } from './utils';
35

46
describe('generated-locales', () => {
57
const date = new Date(2000, 0, 1);
68

7-
describe.each(LOCALES)('%s (calendar)', (locale) => {
8-
beforeAll(() => {
9-
const calendar = require(`./locales/${ locale }/calendar`).default;
10-
setData(calendar);
9+
describe.each(LOCALES)('%s (calendar)', async(locale) => {
10+
beforeAll(async () => {
11+
const calendar = await import(`./locales/${ locale }/calendar.js`);
12+
await vi.dynamicImportSettled();
13+
14+
setData(calendar.default);
1115
});
1216

1317
afterAll(() => {

locale-tests/currency.test.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
import { afterAll, beforeAll, describe, it, expect, vi } from 'vitest';
12
import { formatNumber, parseNumber, setData } from '../src/main';
23
import { LOCALES, clean, NO_CURRENCY_LOCALE } from './utils';
34

45
const number = 5.55;
56
const numberString = '5.55';
67
const currencyLocales = LOCALES.filter(locale => locale !== NO_CURRENCY_LOCALE);
78

8-
describe.each(currencyLocales)('%s currency', (locale) => {
9-
beforeAll(() => {
10-
const numbers = require(`./locales/${ locale }/numbers`).default;
11-
const currencies = require(`./locales/${ locale }/currencies`).default;
12-
13-
setData(numbers);
14-
setData(currencies);
9+
describe.each(currencyLocales)('%s currency', async(locale) => {
10+
beforeAll(async() => {
11+
const numbers = await import(`./locales/${ locale }/numbers.js`);
12+
const currencies = await import(`./locales/${ locale }/currencies.js`);
13+
await vi.dynamicImportSettled();
1514

15+
setData(numbers.default);
16+
setData(currencies.default);
1617
});
1718

1819
afterAll(() => {

locale-tests/numbers.test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
import { afterAll, beforeAll, describe, it, expect, vi } from 'vitest';
12
import { formatNumber, parseNumber, setData } from '../src/main';
23
import { LOCALES, clean } from './utils';
34

45
describe('generated-locales', () => {
56
const number = 5.55;
67
const numberString = '5.55';
78

8-
describe.each(LOCALES)('%s numbers', (locale) => {
9-
beforeAll(() => {
10-
const numbers = require(`./locales/${ locale }/numbers`).default;
11-
setData(numbers);
9+
describe.each(LOCALES.slice(0, 1))('%s numbers', async(locale) => {
10+
beforeAll(async () => {
11+
const numbers = await import(`./locales/${ locale }/numbers.js`);
12+
await vi.dynamicImportSettled();
13+
setData(numbers.default);
1214
});
1315

1416
afterAll(() => {

0 commit comments

Comments
 (0)