Skip to content

Commit

Permalink
Adds simple test for translation files
Browse files Browse the repository at this point in the history
  • Loading branch information
hovancik committed Aug 11, 2024
1 parent 402f87a commit 12238d9
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 12238d9

Please sign in to comment.