UNPKG

@vscode/js-debug-browsers

Version:

Browser launch and discovery logic used in VS Code's JavaScript Debugger

87 lines 3.36 kB
"use strict"; /*--------------------------------------------------------- * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); const sinon_1 = require("sinon"); const chai_1 = require("chai"); const darwinFirefox_1 = require("./darwinFirefox"); describe('darwin: firefox', () => { const lsreturn = [ '/Applications/Firefox.app', ' /Applications/Firefox Developer Edition.app', ' /Applications/Firefox Nightly.app', ]; const setup = (options) => { const execa = { command: (0, sinon_1.stub)().resolves({ stdout: options.lsreturn.join('\n') }), }; const fs = { access: (path) => { if (!options.pathsThatExist.includes(path)) { throw new Error('no access here!'); } }, }; const finder = new darwinFirefox_1.DarwinFirefoxBrowserFinder({ FIREFOX_PATH: '/custom/path' }, fs, execa); return finder; }; it('does not return when paths dont exist', async () => { (0, chai_1.expect)(await setup({ lsreturn, pathsThatExist: [], }).findAll()).to.be.empty; }); it('returns and orders correctly', async () => { (0, chai_1.expect)(await setup({ lsreturn, pathsThatExist: [ '/custom/path/Contents/MacOS/firefox', '/Applications/Firefox.app/Contents/MacOS/firefox', '/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox', '/Applications/Firefox Nightly.app/Contents/MacOS/firefox', ], }).findAll()).to.deep.equal([ { path: '/custom/path/Contents/MacOS/firefox', quality: "custom" /* Custom */, }, { path: '/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox', quality: "dev" /* Dev */, }, { path: '/Applications/Firefox Nightly.app/Contents/MacOS/firefox', quality: "canary" /* Canary */, }, { path: '/Applications/Firefox.app/Contents/MacOS/firefox', quality: "stable" /* Stable */, }, ]); }); it('finds well-known paths', async () => { const s = setup({ lsreturn, pathsThatExist: [ '/custom/path/Contents/MacOS/firefox', '/Applications/Firefox Developer Edition.app/Contents/MacOS/firefox', '/Applications/Firefox.app/Contents/MacOS/firefox', ], }); let calls = 0; (0, chai_1.expect)(await s.findWhere((exe) => { calls++; return exe.quality === "stable" /* Stable */; })).to.deep.equal({ path: '/Applications/Firefox.app/Contents/MacOS/firefox', quality: "stable" /* Stable */, }); (0, chai_1.expect)(calls).to.equal(1); (0, chai_1.expect)(await s.findWhere((exe) => { calls++; return exe.quality === "canary" /* Canary */; })).to.be.undefined; }); }); //# sourceMappingURL=darwinFirefox.test.js.map