Add test for core URI handler window-selection logic

This commit is contained in:
Michelle Tilley 2017-11-02 13:35:29 -07:00
parent cbf2d24d9e
commit db0fd527ce
No known key found for this signature in database
GPG Key ID: CD86C13E51F378DA

View File

@ -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)
})
})
})