Files
factorio-clusterio/test/integration/export.js
T
Hornwitser 8c4d2db192 Move TypeScript Node.js build to dist/node
Use a separate folder for the TypeScript build for Node.js in the dist
folder.  This makes each type of build consistently have its own output
folder instead of being interleaved with the Node.js build.
2024-02-08 03:20:26 +01:00

36 lines
1.2 KiB
JavaScript

"use strict";
const assert = require("assert").strict;
const path = require("path");
const { _exportLocale } = require("@clusterio/host/dist/node/src/export");
const { FactorioServer } = require("@clusterio/host/dist/node/src/server");
describe("Integration of lib/factorio/export", function() {
describe("exportLocale()", function() {
it("returns a nested Map with base game locale information", async function() {
let writePath = path.join("temp", "test", "server");
let testServer = new FactorioServer("factorio", writePath, {});
await testServer.init();
let locale = await _exportLocale(testServer, new Map(), ["base"], "en");
assert(locale instanceof Map, "locale is not a map");
assert.equal(locale.get("entity-name.fish"), "Fish");
assert.equal(locale.get("entity-name.small-lamp"), "Lamp");
let empty_keys = 0;
for (let [key, value] of locale) {
// key is always a string
assert.equal(typeof key, "string");
// Value is always a string, nearly always truthy
if (!value) {
empty_keys += 1;
}
assert.equal(typeof value, "string");
}
assert(empty_keys < 10, `Got unusually high amount (${empty_keys}) of empty keys`);
});
});
});