1 |
|
2 |
|
3 | import { assert } from "chai"
|
4 | import importer from "../src/importer"
|
5 |
|
6 | describe("import xlsx file", () =>
|
7 | it("imports xlsx to localization", function () {
|
8 | const oldDataFile = __dirname + "/exportSample/localizedExportTest.json"
|
9 | const newDataFile = __dirname + "/exportSample/localizedExportResult.json"
|
10 | const importFile = __dirname + "/exportSample/toBeImported.xlsx"
|
11 |
|
12 | const localizations = importer(oldDataFile, importFile, newDataFile)
|
13 | assert.equal(localizations.locales.length, 3)
|
14 | assert.equal(localizations.locales[0].code, "en")
|
15 | assert.equal(localizations.locales[1].code, "fr")
|
16 | assert.equal(localizations.locales[2].code, "es")
|
17 |
|
18 | return assert.deepEqual(
|
19 | localizations,
|
20 | {
|
21 | locales: [
|
22 | {
|
23 | code: "en",
|
24 | name: "English"
|
25 | },
|
26 | {
|
27 | code: "fr",
|
28 | name: "French"
|
29 | },
|
30 | {
|
31 | code: "es",
|
32 | name: "Spanish"
|
33 | }
|
34 | ],
|
35 | strings: [
|
36 | {
|
37 | _base: "fr",
|
38 | en: "plane",
|
39 | fr: "avion",
|
40 | es: "avión"
|
41 | },
|
42 | {
|
43 | _base: "es",
|
44 | en: "throw",
|
45 | es: "botar",
|
46 | fr: "jeter"
|
47 | },
|
48 | {
|
49 | _base: "fr",
|
50 | fr: "chien",
|
51 | en: "dog",
|
52 | es: "perro"
|
53 | },
|
54 | {
|
55 | _base: "en",
|
56 | en: "dog",
|
57 | es: "perro",
|
58 | fr: "chien"
|
59 | }
|
60 | ]
|
61 | },
|
62 | JSON.stringify(localizations, null, 2)
|
63 | )
|
64 | }))
|