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