From eab9d7b3bab3740eb45c4fb2418381ac6ab3f0c7 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Fri, 13 Nov 2015 09:15:11 -0600 Subject: [PATCH] Reorganize i18n tests. --- test/api/v3/unit/libs/i18n.test.js | 48 +++++++++++++++++------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/test/api/v3/unit/libs/i18n.test.js b/test/api/v3/unit/libs/i18n.test.js index 8acef06486..5bafc201dc 100644 --- a/test/api/v3/unit/libs/i18n.test.js +++ b/test/api/v3/unit/libs/i18n.test.js @@ -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); }); }); });