Files
habitica/test/api/v3/unit/libs/i18n.test.js
2016-01-03 09:47:27 -06:00

47 lines
1.1 KiB
JavaScript

import {
translations,
localePath,
langCodes,
} from '../../../../../website/src/libs/api-v3/i18n';
import fs from 'fs';
import path from 'path';
describe('i18n', () => {
let listOfLocales = [];
before((done) => {
fs.readdir(localePath, (err, files) => {
if (err) return done(err);
files.forEach((file) => {
if (fs.statSync(path.join(localePath, file)).isDirectory() === false) return;
listOfLocales.push(file);
});
listOfLocales = listOfLocales.sort();
done();
});
});
describe('translations', () => {
it('includes a translation object for each locale', () => {
listOfLocales.forEach((locale) => {
expect(translations[locale]).to.be.an('object');
});
});
});
describe('localePath', () => {
it('is an absolute path to common/locales/', () => {
expect(localePath).to.match(/.*\/common\/locales\//);
expect(localePath);
});
});
describe('langCodes', () => {
it('is a list of all the language codes', () => {
expect(langCodes.sort()).to.eql(listOfLocales);
});
});
});