habitica-self-host/test/api/v3/unit/libs/i18n.test.js

40 lines
925 B
JavaScript
Raw Normal View History

2015-11-12 15:24:08 +00:00
import {
translations,
localePath,
langCodes,
} from '../../../../../website/server/libs/api-v3/i18n';
2015-11-12 15:24:08 +00:00
import fs from 'fs';
import path from 'path';
describe('i18n', () => {
2015-11-13 15:15:11 +00:00
let listOfLocales = [];
before((done) => {
fs.readdir(localePath, (err, files) => {
if (err) return done(err);
2015-11-12 15:24:08 +00:00
2015-11-13 15:15:11 +00:00
files.forEach((file) => {
if (fs.statSync(path.join(localePath, file)).isDirectory() === false) return;
listOfLocales.push(file);
});
2015-11-12 15:24:08 +00:00
2015-11-13 15:15:11 +00:00
listOfLocales = listOfLocales.sort();
done();
});
});
2015-11-12 15:24:08 +00:00
2015-11-13 15:15:11 +00:00
describe('translations', () => {
it('includes a translation object for each locale', () => {
listOfLocales.forEach((locale) => {
expect(translations[locale]).to.be.an('object');
2015-11-12 15:24:08 +00:00
});
});
2015-11-13 15:15:11 +00:00
});
2015-11-12 15:24:08 +00:00
2015-11-13 15:15:11 +00:00
describe('langCodes', () => {
it('is a list of all the language codes', () => {
expect(langCodes.sort()).to.eql(listOfLocales);
2015-11-12 15:24:08 +00:00
});
});
});