0022286b46
* first attempt * progress * working * working * test timeago * rm * get timeago working * reduce size * fix whitespace * more intl stuff * more effort * more work * more progress * more work * more intl * set lang=LOCALE * flatten * more work * add ltr/rtl * more work * add comments * yet more work * still more work * more work * fix tests * more test and string fixes * fix test * fix test * fix test * fix some more strings, add test * fix snackbar * fix } * fix typo * fix english * measure perf * start on french * more work on french * more french * more french * finish french * fix some missing translations * update readme * fix test
32 lines
1,015 B
JavaScript
32 lines
1,015 B
JavaScript
// this test is to make sure I don't shoot myself in the foot and typo something and show the user
|
|
// a string like intl.nameOfThing rather than "Name of Thing"
|
|
|
|
/* global describe it */
|
|
|
|
import enIntl from '../../src/intl/en-US'
|
|
import globby from 'globby'
|
|
import path from 'path'
|
|
import { promisify } from 'util'
|
|
import fs from 'fs'
|
|
import assert from 'assert'
|
|
|
|
const readFile = promisify(fs.readFile)
|
|
|
|
describe('test-intl.js', () => {
|
|
it('has no unused intl strings', async () => {
|
|
const keys = Object.keys(enIntl)
|
|
|
|
const allSourceFilenames = (await globby([path.join(__dirname, '../../src/**/*.{js,html}')]))
|
|
.filter(file => !file.includes('/intl/'))
|
|
const allSourceFiles = await Promise.all(
|
|
allSourceFilenames.map(async name => ({ name, content: await readFile(name, 'utf8') }))
|
|
)
|
|
for (const key of keys) {
|
|
assert(
|
|
allSourceFiles.some(({ content }) => content.includes(`intl.${key}`)),
|
|
`Unused intl string: ${JSON.stringify(key)}`
|
|
)
|
|
}
|
|
})
|
|
})
|