mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Test empty command-line cases
This commit is contained in:
@@ -56,6 +56,12 @@ describe('AtomApplication', function () {
|
||||
|
||||
describe('command-line interface behavior', function () {
|
||||
describe('with no open windows', function () {
|
||||
// This is also the case when a user selects the application from the OS shell
|
||||
it('opens an empty window', async function () {
|
||||
await scenario.launch(parseCommandLine([]))
|
||||
await scenario.assert('[_ _]')
|
||||
})
|
||||
|
||||
// This is also the case when a user clicks on a file in their file manager
|
||||
it('opens a file', async function () {
|
||||
await scenario.open(parseCommandLine(['a/1.md']))
|
||||
@@ -182,6 +188,12 @@ describe('AtomApplication', function () {
|
||||
await scenario.preconditions('[_ _]')
|
||||
})
|
||||
|
||||
// This is also the case when a user selects the application from the OS shell
|
||||
it('opens a new, empty window', async function () {
|
||||
await scenario.open(parseCommandLine([]))
|
||||
await scenario.assert('[_ _] [_ _]')
|
||||
})
|
||||
|
||||
// This is also the case when a user clicks on a file in their file manager
|
||||
it('opens a file', async function () {
|
||||
await scenario.open(parseCommandLine(['a/1.md']))
|
||||
@@ -220,6 +232,12 @@ describe('AtomApplication', function () {
|
||||
await scenario.preconditions('[a _]')
|
||||
})
|
||||
|
||||
// This is also the case when a user selects the application from the OS shell
|
||||
it('opens a new, empty window', async function () {
|
||||
await scenario.open(parseCommandLine([]))
|
||||
await scenario.assert('[a _] [_ _]')
|
||||
})
|
||||
|
||||
// This is also the case when a user clicks on a file within the project root in their file manager
|
||||
it('opens a file within the project root', async function () {
|
||||
await scenario.open(parseCommandLine(['a/1.md']))
|
||||
@@ -290,6 +308,12 @@ describe('AtomApplication', function () {
|
||||
await scenario.preconditions('[a _] [_ _]')
|
||||
})
|
||||
|
||||
// This is also the case when a user selects the application from the OS shell
|
||||
it('opens a new, empty window', async function () {
|
||||
await scenario.open(parseCommandLine([]))
|
||||
await scenario.assert('[a _] [_ _] [_ _]')
|
||||
})
|
||||
|
||||
// This is also the case when a user clicks on a file within the project root in their file manager
|
||||
it('opens a file within the project root', async function () {
|
||||
await scenario.open(parseCommandLine(['a/1.md']))
|
||||
@@ -360,6 +384,12 @@ describe('AtomApplication', function () {
|
||||
await scenario.preconditions('[_ _] [a _]')
|
||||
})
|
||||
|
||||
// This is also the case when a user selects the application from the OS shell
|
||||
it('opens a new, empty window', async function () {
|
||||
await scenario.open(parseCommandLine([]))
|
||||
await scenario.assert('[_ _] [a _] [_ _]')
|
||||
})
|
||||
|
||||
// This is also the case when a user clicks on a file within the project root in their file manager
|
||||
it('opens a file within the project root', async function () {
|
||||
await scenario.open(parseCommandLine(['a/1.md']))
|
||||
|
||||
@@ -349,6 +349,7 @@ class AtomApplication extends EventEmitter {
|
||||
} else {
|
||||
// Always open an editor window if this is the first instance of Atom.
|
||||
return this.openPath({
|
||||
pathToOpen: null,
|
||||
pidToKillWhenClosed,
|
||||
newWindow,
|
||||
devMode,
|
||||
@@ -991,15 +992,18 @@ class AtomApplication extends EventEmitter {
|
||||
return
|
||||
}
|
||||
|
||||
const hasNonEmptyPath = locationsToOpen.some(location => location.pathToOpen)
|
||||
const createNewWindow = newWindow || !hasNonEmptyPath
|
||||
|
||||
let existingWindow
|
||||
|
||||
if (!newWindow) {
|
||||
if (!createNewWindow) {
|
||||
// An explicitly provided AtomWindow has precedence.
|
||||
existingWindow = window
|
||||
|
||||
// If no window is specified and at least one path is provided, locate an existing window that contains all
|
||||
// provided paths.
|
||||
if (!existingWindow && locationsToOpen.some(location => location.pathToOpen)) {
|
||||
if (!existingWindow && hasNonEmptyPath) {
|
||||
existingWindow = this.windowForLocations(locationsToOpen, devMode, safeMode)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user