| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- let test = 1;
- const check = (value, expect) => {
- console.log("Running test " + test + "...");
- test = test + 1;
- if (value.toString() === expect.toString()) {
- console.log("Pass.");
- console.log("");
- return;
- }
- console.log("FAIL!!!");
- console.log("Expected: \"" + expect.toString() + "\".");
- console.log("Result: \"" + value.toString() + "\".");
- console.log("");
- }
- const test_all = async () => {
- console.log("Loading and testing loader + phrasebook.");
- const libtranslate = require("../source/core.js");
-
- const flat = await new libtranslate
- .loader("test/flat.json", true)
- .load();
- check(flat.get("test a"), "Test A");
- check(flat.get("simple"), "prosta");
- console.log("Loading and testing languages library.");
- const langs = await new libtranslate
- .languages("test/", true)
- .load("index.json");
- const loaded = await langs.select("pl_PL");
- check(loaded.get("test a"), "Test A");
- console.log("Testing objects notation.");
- const obj = await langs.select("en_US");
- check(obj.get("test.result"), "yes");
- check(obj.get("test a"), "Test A");
-
- console.log("Testing format.");
- check(obj.get("test.format").format({ many: 10 }), "More than 10");
- };
- test_all();
|