Skip to content

Commit

Permalink
Merge pull request #1474 from hovancik/test-trans
Browse files Browse the repository at this point in the history
Adds simple test for translation files
  • Loading branch information
hovancik authored Aug 11, 2024
2 parents af3b1af + 12238d9 commit bedd10c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { readFileSync, readdirSync } from 'fs'
import { join } from 'path'
import { expect } from 'vitest'

const jsonDirectory = join(__dirname, '../app/locales')

function getJsonFiles (dir) {
return readdirSync(dir).filter(file => file.endsWith('.json'))
}

describe('Translations files', () => {
const jsonFiles = getJsonFiles(jsonDirectory)

jsonFiles.forEach(file => {
it(`${file} is valid`, () => {
const filePath = join(jsonDirectory, file)
const data = readFileSync(filePath, 'utf8')

expect(() => {
JSON.parse(data)
}).not.toThrow()
})
})
})

0 comments on commit bedd10c

Please sign in to comment.