which-electron/tests/finder.js

49 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-07-16 06:50:21 +00:00
const test = require("kuta").test;
const finder = require("../finder");
const assert = require("assert");
const fs = require("fs");
2021-07-16 06:44:38 +00:00
function getEntries(fn) {
2021-07-16 06:50:21 +00:00
return JSON.parse(fs.readFileSync(`./tests/fixtures/${fn}.json`));
2021-07-16 06:44:38 +00:00
}
2021-07-16 06:50:21 +00:00
test("it should find the electron.asar file", () => {
2021-07-16 06:44:38 +00:00
assert.deepEqual(
2021-07-16 06:50:21 +00:00
["Hyper.app/Contents/Resources/electron.asar"],
finder.asar(getEntries("Hyper-3.0.2-mac.zip"))
);
2021-07-16 06:44:38 +00:00
});
2021-07-16 06:50:21 +00:00
test("it should find the correct binary file", () => {
2021-07-16 06:44:38 +00:00
assert.deepEqual(
2021-07-16 06:50:21 +00:00
"Hyper.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework",
finder.binary(getEntries("Hyper-3.0.2-mac.zip"))
);
2021-07-16 06:44:38 +00:00
assert.deepEqual(
2021-07-16 06:50:21 +00:00
"Notable.exe",
finder.binary(getEntries("Notable-1.8.4-win.zip"))
);
2021-07-16 06:44:38 +00:00
assert.deepEqual(
2021-07-16 06:50:21 +00:00
"rambox",
finder.binary(getEntries("Rambox-0.7.7-linux-x64.zip"))
);
});
test("it should find the version file", () => {
assert.deepEqual(
["chronobreak-linux-x64/version"],
finder.version(getEntries("chronobreak-linux-x64.zip"))
);
assert.deepEqual(
["release-builds/encrypt0r-darwin-x64/version"],
finder.version(getEntries("encrypt0r-mac.zip"))
);
assert.deepEqual(
[
"Arizona v.1.0.0/resources/app/node_modules/electron/dist/version",
"Arizona v.1.0.0/version",
],
finder.version(getEntries("Arizona-v1.0.0-beta-Windows.zip"))
);
});