From 2d3e34a65a68442202903de466633cf49cd77e03 Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Thu, 21 Nov 2024 09:01:22 +0100 Subject: [PATCH] fix tests --- test/backend.caching.js | 2 +- test/backend.js.js | 2 +- test/backend.json.js | 2 +- test/backend.json5.js | 2 +- test/backend.jsonc.js | 2 +- test/backend.yaml.js | 2 +- test/bun/backend.caching.test.js | 2 +- test/bun/backend.js.test.js | 2 +- test/bun/backend.json.test.js | 2 +- test/bun/backend.json5.test.js | 12 +++++++----- test/bun/backend.jsonc.test.js | 17 +++++++++-------- test/bun/backend.yaml.test.js | 2 +- test/deno/backend.caching.js | 2 +- test/deno/backend.js.js | 2 +- test/deno/backend.json.js | 2 +- test/deno/backend.json5.js | 2 +- test/deno/backend.jsonc.js | 2 +- test/deno/backend.yaml.js | 2 +- 18 files changed, 32 insertions(+), 29 deletions(-) diff --git a/test/backend.caching.js b/test/backend.caching.js index 36cd1f7..938d62b 100644 --- a/test/backend.caching.js +++ b/test/backend.caching.js @@ -6,7 +6,7 @@ import i18next from 'i18next' import Backend from '../index.js' import { removeFile } from '../lib/writeFile.js' -i18next.init() +i18next.init({ fallbackLng: 'en', ns: 'test' }) describe('BackendConnector as caching layer', () => { let connector diff --git a/test/backend.js.js b/test/backend.js.js index a18f3c4..45c7c9c 100644 --- a/test/backend.js.js +++ b/test/backend.js.js @@ -6,7 +6,7 @@ import i18next from 'i18next' import Backend from '../index.js' import { writeFile } from '../lib/writeFile.js' -i18next.init() +i18next.init({ fallbackLng: 'en', ns: 'test' }) describe('BackendConnector with js', () => { let connector diff --git a/test/backend.json.js b/test/backend.json.js index aeaddc9..601043b 100644 --- a/test/backend.json.js +++ b/test/backend.json.js @@ -6,7 +6,7 @@ import i18next from 'i18next' import Backend from '../index.js' import { writeFile } from '../lib/writeFile.js' -i18next.init() +i18next.init({ fallbackLng: 'en', ns: 'test' }) describe('BackendConnector with normal json', () => { let connector diff --git a/test/backend.json5.js b/test/backend.json5.js index 8f11c68..18407ec 100644 --- a/test/backend.json5.js +++ b/test/backend.json5.js @@ -7,7 +7,7 @@ import i18next from 'i18next' import Backend from '../index.js' import { writeFile } from '../lib/writeFile.js' -i18next.init() +i18next.init({ fallbackLng: 'en', ns: 'test' }) describe('BackendConnector with json5', () => { let connector diff --git a/test/backend.jsonc.js b/test/backend.jsonc.js index ff422dd..f1cee4c 100644 --- a/test/backend.jsonc.js +++ b/test/backend.jsonc.js @@ -7,7 +7,7 @@ import i18next from 'i18next' import Backend from '../index.js' import { writeFile } from '../lib/writeFile.js' -i18next.init() +i18next.init({ fallbackLng: 'en', ns: 'test' }) describe('BackendConnector with jsonc', () => { let connector diff --git a/test/backend.yaml.js b/test/backend.yaml.js index 82fa10e..5c08a3c 100644 --- a/test/backend.yaml.js +++ b/test/backend.yaml.js @@ -6,7 +6,7 @@ import i18next from 'i18next' import Backend from '../index.js' import { writeFile } from '../lib/writeFile.js' -i18next.init() +i18next.init({ fallbackLng: 'en', ns: 'test' }) describe('BackendConnector with yaml', () => { let connector diff --git a/test/bun/backend.caching.test.js b/test/bun/backend.caching.test.js index d72800f..80aa00f 100644 --- a/test/bun/backend.caching.test.js +++ b/test/bun/backend.caching.test.js @@ -3,7 +3,7 @@ import i18next from 'i18next' import Backend from '../../index.js' import { removeFile } from '../../lib/writeFile.js' -i18next.init() +i18next.init({ fallbackLng: 'en', ns: 'test' }) describe('BackendConnector as caching layer', () => { let connector diff --git a/test/bun/backend.js.test.js b/test/bun/backend.js.test.js index c605a35..cc5a3fa 100644 --- a/test/bun/backend.js.test.js +++ b/test/bun/backend.js.test.js @@ -3,7 +3,7 @@ import i18next from 'i18next' import Backend from '../../index.js' import { writeFile } from '../../lib/writeFile.js' -i18next.init() +i18next.init({ fallbackLng: 'en', ns: 'test' }) describe.skip('BackendConnector with js', () => { let connector diff --git a/test/bun/backend.json.test.js b/test/bun/backend.json.test.js index e4da500..e84935e 100644 --- a/test/bun/backend.json.test.js +++ b/test/bun/backend.json.test.js @@ -3,7 +3,7 @@ import i18next from 'i18next' import Backend from '../../index.js' import { writeFile } from '../../lib/writeFile.js' -i18next.init() +i18next.init({ fallbackLng: 'en', ns: 'test' }) describe('BackendConnector with normal json', () => { let connector diff --git a/test/bun/backend.json5.test.js b/test/bun/backend.json5.test.js index e050b24..b5ed014 100644 --- a/test/bun/backend.json5.test.js +++ b/test/bun/backend.json5.test.js @@ -3,7 +3,7 @@ import i18next from 'i18next' import Backend from '../../index.js' import { writeFile } from '../../lib/writeFile.js' -i18next.init() +i18next.init({ fallbackLng: 'en', ns: 'test' }) describe('BackendConnector with json5', () => { let connector @@ -16,14 +16,15 @@ describe('BackendConnector with json5', () => { }) writeFile(`${import.meta.dir}/../locales/en/test.json5`, { key: 'passing' }) .then(() => { - Bun.writeFile(`${import.meta.dir}/../locales/en/test-with-comments.json5`, `{ + Bun.write(`${import.meta.dir}/../locales/en/test-with-comments.json5`, `{ "key": "passing", // line comment "commented": "value", /* inline block */ /* block comment multiple lines */ "block": "value" - }`, done) + }`) + done() }) .catch(done) }) @@ -31,14 +32,15 @@ describe('BackendConnector with json5', () => { afterEach((done) => { writeFile(`${import.meta.dir}/../locales/en/test.json5`, { key: 'passing' }) .then(() => { - Bun.writeFile(`${import.meta.dir}/../locales/en/test-with-comments.json5`, `{ + Bun.write(`${import.meta.dir}/../locales/en/test-with-comments.json5`, `{ "key": "passing", // line comment "commented": "value", /* inline block */ /* block comment multiple lines */ "block": "value" - }`, done) + }`) + done() }) .catch(done) }) diff --git a/test/bun/backend.jsonc.test.js b/test/bun/backend.jsonc.test.js index 8c4951e..41e5fea 100644 --- a/test/bun/backend.jsonc.test.js +++ b/test/bun/backend.jsonc.test.js @@ -2,9 +2,8 @@ import { expect, test, describe, beforeEach, afterEach } from "bun:test" import i18next from 'i18next' import Backend from '../../index.js' import { writeFile } from '../../lib/writeFile.js' -import fs from 'node:fs' -i18next.init() +i18next.init({ fallbackLng: 'en', ns: 'test' }) describe('BackendConnector with jsonc', () => { let connector @@ -15,16 +14,17 @@ describe('BackendConnector with jsonc', () => { loadPath: `${import.meta.dir}/../locales/{{lng}}/{{ns}}.jsonc`, addPath: `${import.meta.dir}/../locales/{{lng}}/{{ns}}.jsonc` }) - writeFile(`${import.meta.dir}/locales/en/test.jsonc`, { key: 'passing' }) + writeFile(`${import.meta.dir}/../locales/en/test.jsonc`, { key: 'passing' }) .then(() => { - fs.writeFile(`${import.meta.dir}/locales/en/test-with-comments.jsonc`, `{ + Bun.write(`${import.meta.dir}/../locales/en/test-with-comments.jsonc`, `{ "key": "passing", // line comment "commented": "value", /* inline block */ /* block comment multiple lines */ "block": "value" - }`, done) + }`) + done() }) .catch(done) }) @@ -32,14 +32,15 @@ describe('BackendConnector with jsonc', () => { afterEach((done) => { writeFile(`${import.meta.dir}/../locales/en/test.jsonc`, { key: 'passing' }) .then(() => { - fs.writeFile(`${import.meta.dir}/../locales/en/test-with-comments.jsonc`, `{ + Bun.write(`${import.meta.dir}/../locales/en/test-with-comments.jsonc`, `{ "key": "passing", // line comment "commented": "value", /* inline block */ /* block comment multiple lines */ "block": "value" - }`, done) + }`) + done() }) .catch(done) }) @@ -57,7 +58,7 @@ describe('BackendConnector with jsonc', () => { test('should load data with comments', (done) => { connector.load(['en'], ['test-with-comments'], (err) => { - expect(err).not.toBeFalsy() + expect(err).toBeFalsy() expect(connector.store.getResourceBundle('en', 'test-with-comments')).toEqual({ key: 'passing', commented: 'value', diff --git a/test/bun/backend.yaml.test.js b/test/bun/backend.yaml.test.js index 98bccc8..80ff32d 100644 --- a/test/bun/backend.yaml.test.js +++ b/test/bun/backend.yaml.test.js @@ -3,7 +3,7 @@ import i18next from 'i18next' import Backend from '../../index.js' import { writeFile } from '../../lib/writeFile.js' -i18next.init() +i18next.init({ fallbackLng: 'en', ns: 'test' }) describe('BackendConnector with yaml', () => { let connector diff --git a/test/deno/backend.caching.js b/test/deno/backend.caching.js index 4e50640..516c772 100644 --- a/test/deno/backend.caching.js +++ b/test/deno/backend.caching.js @@ -9,7 +9,7 @@ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) test('BackendConnector as caching layer', async () => { // before - i18next.init() + i18next.init({ fallbackLng: 'en', ns: 'test' }) const connector = i18next.services.backendConnector connector.backend = new Backend(i18next.services, { diff --git a/test/deno/backend.js.js b/test/deno/backend.js.js index f1437ce..9291690 100644 --- a/test/deno/backend.js.js +++ b/test/deno/backend.js.js @@ -9,7 +9,7 @@ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) test('BackendConnector with js', async () => { // before - i18next.init() + i18next.init({ fallbackLng: 'en', ns: 'test' }) const connector = i18next.services.backendConnector connector.backend = new Backend(i18next.services, { diff --git a/test/deno/backend.json.js b/test/deno/backend.json.js index 5a7ec2c..84ff9ed 100644 --- a/test/deno/backend.json.js +++ b/test/deno/backend.json.js @@ -9,7 +9,7 @@ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) test('BackendConnector with normal json', async () => { // before - i18next.init() + i18next.init({ fallbackLng: 'en', ns: 'test' }) const connector = i18next.services.backendConnector connector.backend = new Backend(i18next.services, { diff --git a/test/deno/backend.json5.js b/test/deno/backend.json5.js index 73a7dc8..54fd86d 100644 --- a/test/deno/backend.json5.js +++ b/test/deno/backend.json5.js @@ -9,7 +9,7 @@ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) test('BackendConnector with json5', async () => { // before - i18next.init() + i18next.init({ fallbackLng: 'en', ns: 'test' }) const connector = i18next.services.backendConnector connector.backend = new Backend(i18next.services, { diff --git a/test/deno/backend.jsonc.js b/test/deno/backend.jsonc.js index f4a01c0..3d27cfc 100644 --- a/test/deno/backend.jsonc.js +++ b/test/deno/backend.jsonc.js @@ -9,7 +9,7 @@ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) test('BackendConnector with jsonc', async () => { // before - i18next.init() + i18next.init({ fallbackLng: 'en', ns: 'test' }) const connector = i18next.services.backendConnector connector.backend = new Backend(i18next.services, { diff --git a/test/deno/backend.yaml.js b/test/deno/backend.yaml.js index 634a0dd..433b9e4 100644 --- a/test/deno/backend.yaml.js +++ b/test/deno/backend.yaml.js @@ -9,7 +9,7 @@ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) test('BackendConnector with yaml', async () => { // before - i18next.init() + i18next.init({ fallbackLng: 'en', ns: 'test' }) const connector = i18next.services.backendConnector connector.backend = new Backend(i18next.services, {