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