From db0fd527cea4ff6bc203a599f772303c6e950dbc Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Thu, 2 Nov 2017 13:35:29 -0700 Subject: [PATCH] Add test for core URI handler window-selection logic --- spec/main-process/atom-application.test.js | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spec/main-process/atom-application.test.js b/spec/main-process/atom-application.test.js index 6434710ce..a209b4301 100644 --- a/spec/main-process/atom-application.test.js +++ b/spec/main-process/atom-application.test.js @@ -461,6 +461,30 @@ describe('AtomApplication', function () { assert.equal(reached, true); windows[0].close(); }) + + it('triggers /core/open/file in the correct window', async function() { + const dirAPath = makeTempDir('a') + const dirBPath = makeTempDir('b') + + const atomApplication = buildAtomApplication() + const window1 = atomApplication.launch(parseCommandLine([path.join(dirAPath)])) + await focusWindow(window1) + const window2 = atomApplication.launch(parseCommandLine([path.join(dirBPath)])) + await focusWindow(window2) + + await new Promise(res => setTimeout(res, 2000)) + + const fileA = path.join(dirAPath, 'file-a') + const fileB = path.join(dirBPath, 'file-b') + + atomApplication.launch(parseCommandLine(['--uri-handler', `atom://core/open/file?filename=${fileA}`])) + await new Promise(res => setTimeout(res, 1000)) + assert.equal(atomApplication.getLastFocusedWindow(), window1) + + atomApplication.launch(parseCommandLine(['--uri-handler', `atom://core/open/file?filename=${fileB}`])) + await new Promise(res => setTimeout(res, 1000)) + assert.equal(atomApplication.getLastFocusedWindow(), window2) + }) }) })