Skip to content

Commit

Permalink
Test for missing keys
Browse files Browse the repository at this point in the history
Added lodash
Added a test that fails if the number of keys in one language file doesn't match the number in the other.
Will spit out the extra keys if it fails.
  • Loading branch information
CalvinRodo committed Jun 18, 2019
1 parent c42bb47 commit d66d6ff
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"eslint-plugin-vue": "^5.0.0",
"fibers": "^3.1.1",
"jest-transform-stub": "^2.0.0",
"lodash": "^4.17.11",
"sass": "^1.17.2",
"sass-loader": "^7.1.0",
"ts-jest": "^23.0.0",
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/i18n.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

import en from "@/plugins/en.json";
import fr from "@/plugins/fr.json";
import _ from "lodash";

const enKeys = Object.keys(en);
const frKeys = Object.keys(fr);

describe("i18n", () => {
it("should have identical keys", () => {
const val = _.difference(enKeys, frKeys);
const enIntersection = _.intersection(enKeys, val);
const mek = enIntersection.join("\n")
const frIntersection = _.intersection(frKeys, val);
const mfk = frIntersection.join("\n");

console.log(`
extra keys in en.json
${mek}
extra keys in fr.json
${mfk}`);

expect(Object.keys(val).length).toBe(0);
});


});

0 comments on commit d66d6ff

Please sign in to comment.