From 20244c4fb57fb622be3efbf37d58ed071af64dd1 Mon Sep 17 00:00:00 2001 From: fewieden Date: Thu, 15 Feb 2018 23:22:52 +0100 Subject: [PATCH] translations integration test --- tests/e2e/translations_spec.js | 129 +++++++++++++++++++++++++++ tests/unit/translations/same_keys.js | 118 ------------------------ 2 files changed, 129 insertions(+), 118 deletions(-) create mode 100644 tests/e2e/translations_spec.js delete mode 100644 tests/unit/translations/same_keys.js diff --git a/tests/e2e/translations_spec.js b/tests/e2e/translations_spec.js new file mode 100644 index 00000000..70238550 --- /dev/null +++ b/tests/e2e/translations_spec.js @@ -0,0 +1,129 @@ +const fs = require("fs"); +const path = require("path"); +const chai = require("chai"); +const expect = chai.expect; +const mlog = require("mocha-logger"); +const translations = require("../../translations/translations.js"); +const helmet = require("helmet"); +const {JSDOM} = require("jsdom"); +const express = require("express"); + +describe("Translations", function() { + let server; + + before(function() { + const app = express(); + app.use(helmet()); + app.use(function (req, res, next) { + res.header("Access-Control-Allow-Origin", "*"); + next(); + }); + app.use("/translations", express.static(path.join(__dirname, "..", "..", "translations"))); + + server = app.listen(3000); + }); + + after(function() { + server.close(); + }); + + it("should have a translation file in the specified path", function() { + for(let language in translations) { + const file = fs.statSync(translations[language]); + expect(file.isFile()).to.be.equal(true); + } + }); + + const mmm = { + name: "TranslationTest", + file(file) { + return `http://localhost:3000/${file}`; + } + }; + + describe("Parsing language files through the Translator class", function() { + for(let language in translations) { + it(`should parse ${language}`, function(done) { + const dom = new JSDOM(`\ + \ + \ +