mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Move all functions and classes currently available through lib/name and libName to be under a single flat namespace in lib. This make reorganising the lib namespace much simpler as the location of symbols can move without breaking the consumers of lib. The multi-entrypoint design was already problematic for the web plugin system which couldn't effectively use it due to how webpack's shared module system is awkward to set up with multiple entrypoints per package.
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
"use strict";
|
|
const assert = require("assert").strict;
|
|
const JSZip = require("jszip");
|
|
|
|
const { findRoot } = require("@clusterio/lib");
|
|
|
|
|
|
describe("lib/factorio", function() {
|
|
describe("findRoot()", function() {
|
|
it("should find the root of a zip", function() {
|
|
let zip = new JSZip();
|
|
zip.file("root/foo.txt", "");
|
|
zip.file("root/bar.txt", "");
|
|
|
|
assert.equal(findRoot(zip), "root");
|
|
});
|
|
|
|
it("should throw if files are at the root of the zip", function() {
|
|
let zip = new JSZip();
|
|
zip.file("root/foo.txt", "");
|
|
zip.file("bar.txt", "");
|
|
|
|
assert.throws(
|
|
() => findRoot(zip),
|
|
new Error("Zip contains file 'bar.txt' in root dir")
|
|
);
|
|
});
|
|
|
|
it("should throw if there are multiple root dirs", function() {
|
|
let zip = new JSZip();
|
|
zip.file("root-1/foo.txt", "");
|
|
zip.file("root-2/bar.txt", "");
|
|
|
|
assert.throws(
|
|
() => findRoot(zip),
|
|
new Error("Zip contains multiple root folders")
|
|
);
|
|
});
|
|
|
|
it("should throw if given an empty zip file", function() {
|
|
let zip = new JSZip();
|
|
|
|
assert.throws(
|
|
() => findRoot(zip),
|
|
new Error("Empty zip file")
|
|
);
|
|
});
|
|
});
|
|
});
|