mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 07:04:52 +09:00
Move getFactorioLocale to the new lib/factorio namespace and refactor it to use async functions instead of callbacks. Split tests into integration with factorio and testing of the function itself. Also removes the cacheing from the function itself as this breaks the isolated testing of it.
19 lines
718 B
JavaScript
19 lines
718 B
JavaScript
const assert = require("assert").strict;
|
|
const path = require("path");
|
|
|
|
const factorio = require("lib/factorio");
|
|
|
|
|
|
describe("lib/factorio/locale", function() {
|
|
describe("getLocale()", function() {
|
|
it("verifies types of the arguments", async function() {
|
|
await assert.rejects(factorio.getLocale(1, "a"), new TypeError("dataDir must be a string"));
|
|
await assert.rejects(factorio.getLocale("a", 1), new TypeError("languageCode must be a string"));
|
|
});
|
|
it("returns a nested object with locale definitions", async function() {
|
|
let locale = await factorio.getLocale(path.join("test", "file", "factorio", "data"), "en");
|
|
assert.deepEqual(locale, { test: { "key-a": "1", "key-b": "2" } });
|
|
});
|
|
});;
|
|
});
|