Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Nov 21, 2024
1 parent 4802ab9 commit 2d3e34a
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 29 deletions.
2 changes: 1 addition & 1 deletion test/backend.caching.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/backend.js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/backend.json.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/backend.json5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/backend.jsonc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/backend.yaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/bun/backend.caching.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/bun/backend.js.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/bun/backend.json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions test/bun/backend.json5.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,29 +16,31 @@ 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)
})

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)
})
Expand Down
17 changes: 9 additions & 8 deletions test/bun/backend.jsonc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,31 +14,33 @@ 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)
})

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)
})
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion test/bun/backend.yaml.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/deno/backend.caching.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion test/deno/backend.js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion test/deno/backend.json.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion test/deno/backend.json5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion test/deno/backend.jsonc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion test/deno/backend.yaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 2d3e34a

Please sign in to comment.