Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Feb 27, 2024
1 parent 9564c17 commit 8f8663c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
22 changes: 9 additions & 13 deletions packages/translate/tests/createTranslator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@ describe('createTranslator()', () => {
});

it('errors if no namespace is provided', async () => {
await expect(() => {
createTranslator([], []);
}).resolves.toThrowErrorMatchingSnapshot();
await expect(() => createTranslator([], [])).resolves.toThrowErrorMatchingSnapshot();
});

it('errors if no resource paths are provided', () => {
expect(() => {
createTranslator('common', []);
}).toThrowErrorMatchingSnapshot();
it('errors if no resource paths are provided', async () => {
await expect(() => createTranslator('common', [])).resolves.toThrowErrorMatchingSnapshot();
});

it('errors if `autoDetect` and `locale` are empty', () => {
expect(() => {
createTranslator('common', getFixturePath('i18n-resources'), { autoDetect: false });
}).toThrowErrorMatchingSnapshot();
it('errors if `autoDetect` and `locale` are empty', async () => {
await expect(() =>
createTranslator('common', getFixturePath('i18n-resources'), { autoDetect: false }),
).resolves.toThrowErrorMatchingSnapshot();
});

it('returns a function to load translated messages', () => {
Expand Down Expand Up @@ -64,8 +60,8 @@ describe('createTranslator()', () => {
});

describe('msg()', () => {
beforeEach(() => {
translator = createTranslator('common', [
beforeEach(async () => {
translator = await createTranslator('common', [
getFixturePath('i18n-resources'),
getFixturePath('i18n-resources-more'),
]);
Expand Down
1 change: 1 addition & 0 deletions website/docs/migrate/5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ the new Vitest testing framework.
## @boost/translate

- Added support for `.cjs` and `.mjs` files for translation resources.
- BREAKING: Updated `createTranslator` to be async.

0 comments on commit 8f8663c

Please sign in to comment.