Skip to content

Commit

Permalink
chore: use vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
tsvetomir committed Jan 3, 2025
1 parent 8102ecc commit 2c9565c
Show file tree
Hide file tree
Showing 16 changed files with 15,356 additions and 17,973 deletions.
7 changes: 7 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,12 @@ export default [
},
{
ignores: ["dist/", "docs/"]
},
{
settings: {
"import/ignore": [
"vitest"
],
},
}
];
5 changes: 0 additions & 5 deletions jest.config.json

This file was deleted.

12 changes: 8 additions & 4 deletions locale-tests/all.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { afterAll, beforeAll, describe, it, expect, vi } from 'vitest';

import { formatNumber, parseNumber, formatDate, parseDate, firstDay, weekendRange, setData } from '../src/main';
import { LOCALES, NO_CURRENCY_LOCALE, clean } from './utils';

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

describe.each(LOCALES)('%s (all)', (locale) => {
beforeAll(() => {
const all = require(`./locales/${ locale }/all`).default;
setData(all);
describe.each(LOCALES)('%s (all)', async(locale) => {
beforeAll(async () => {
const all = await import(`./locales/${ locale }/all.js`);
await vi.dynamicImportSettled();

setData(all.default);
});

afterAll(() => {
Expand Down
12 changes: 8 additions & 4 deletions locale-tests/calendar.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { afterAll, beforeAll, describe, it, expect, vi } from 'vitest';

import { formatDate, parseDate, firstDay, weekendRange, setData } from '../src/main';
import { LOCALES, clean } from './utils';

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

describe.each(LOCALES)('%s (calendar)', (locale) => {
beforeAll(() => {
const calendar = require(`./locales/${ locale }/calendar`).default;
setData(calendar);
describe.each(LOCALES)('%s (calendar)', async(locale) => {
beforeAll(async () => {
const calendar = await import(`./locales/${ locale }/calendar.js`);
await vi.dynamicImportSettled();

setData(calendar.default);
});

afterAll(() => {
Expand Down
15 changes: 8 additions & 7 deletions locale-tests/currency.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { afterAll, beforeAll, describe, it, expect, vi } from 'vitest';
import { formatNumber, parseNumber, setData } from '../src/main';
import { LOCALES, clean, NO_CURRENCY_LOCALE } from './utils';

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

describe.each(currencyLocales)('%s currency', (locale) => {
beforeAll(() => {
const numbers = require(`./locales/${ locale }/numbers`).default;
const currencies = require(`./locales/${ locale }/currencies`).default;

setData(numbers);
setData(currencies);
describe.each(currencyLocales)('%s currency', async(locale) => {
beforeAll(async() => {
const numbers = await import(`./locales/${ locale }/numbers.js`);
const currencies = await import(`./locales/${ locale }/currencies.js`);
await vi.dynamicImportSettled();

setData(numbers.default);
setData(currencies.default);
});

afterAll(() => {
Expand Down
10 changes: 6 additions & 4 deletions locale-tests/numbers.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { afterAll, beforeAll, describe, it, expect, vi } from 'vitest';
import { formatNumber, parseNumber, setData } from '../src/main';
import { LOCALES, clean } from './utils';

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

describe.each(LOCALES)('%s numbers', (locale) => {
beforeAll(() => {
const numbers = require(`./locales/${ locale }/numbers`).default;
setData(numbers);
describe.each(LOCALES.slice(0, 1))('%s numbers', async(locale) => {
beforeAll(async () => {
const numbers = await import(`./locales/${ locale }/numbers.js`);
await vi.dynamicImportSettled();
setData(numbers.default);
});

afterAll(() => {
Expand Down
Loading

0 comments on commit 2c9565c

Please sign in to comment.