Adds tests for version finder

This commit is contained in:
Nemo 2021-07-16 12:20:21 +05:30
parent ca9c6ecf25
commit 50de21a2de
4 changed files with 41 additions and 20 deletions

View File

@ -1,30 +1,48 @@
const test = require('kuta').test;
const finder = require('../finder')
const assert = require('assert')
const fs = require('fs')
const test = require("kuta").test;
const finder = require("../finder");
const assert = require("assert");
const fs = require("fs");
function getEntries(fn) {
return JSON.parse(fs.readFileSync(`./tests/fixtures/${fn}.json`))
return JSON.parse(fs.readFileSync(`./tests/fixtures/${fn}.json`));
}
test('it should find the electron.asar file', ()=> {
test("it should find the electron.asar file", () => {
assert.deepEqual(
['Hyper.app/Contents/Resources/electron.asar'],
finder.asar(getEntries('Hyper-3.0.2-mac.zip'))
)
["Hyper.app/Contents/Resources/electron.asar"],
finder.asar(getEntries("Hyper-3.0.2-mac.zip"))
);
});
test('it should find the correct binary file', () => {
test("it should find the correct binary file", () => {
assert.deepEqual(
'Hyper.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework',
finder.binary(getEntries('Hyper-3.0.2-mac.zip'))
)
"Hyper.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework",
finder.binary(getEntries("Hyper-3.0.2-mac.zip"))
);
assert.deepEqual(
'Notable.exe',
finder.binary(getEntries('Notable-1.8.4-win.zip'))
)
"Notable.exe",
finder.binary(getEntries("Notable-1.8.4-win.zip"))
);
assert.deepEqual(
'rambox',
finder.binary(getEntries('Rambox-0.7.7-linux-x64.zip'))
)
})
"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"))
);
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
tests/fixtures/encrypt0r-mac.zip.json vendored Normal file

File diff suppressed because one or more lines are too long