Reorganize i18n tests.

This commit is contained in:
Blade Barringer
2015-11-13 09:15:11 -06:00
parent be672e570c
commit eab9d7b3ba

View File

@@ -7,32 +7,40 @@ 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('loads all locales', (done) => {
fs.readdir(localePath, (err, files) => {
if (err) return done(err);
let locales = [];
files.forEach((file) => {
if (fs.statSync(path.join(localePath, file)).isDirectory() === false) return;
locales.push(file);
});
locales = locales.sort();
let loaded = Object.keys(translations).sort();
expect(locales).to.eql(loaded);
done();
it('includes a translation object for each locale', () => {
listOfLocales.forEach((locale) => {
expect(translations[locale]).to.be.an('object');
});
});
});
it('keeps a list all locales', () => {
expect(Object.keys(translations).sort()).to.eql(langCodes.sort());
describe('localePath', () => {
it('is an absolute path to common/locales/', () => {
expect(localePath).to.match(/.*\/common\/locales\//);
expect(localePath)
});
});
it('has an english translations', () => {
expect(langCodes).to.contain('en');
expect(translations.en).to.be.an('object');
describe('langCodes', () => {
it('is a list of all the language codes', () => {
expect(langCodes.sort()).to.eql(listOfLocales);
});
});
});