-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow open option to accept an object #2492
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
82734a2
feat: allow open option to accept object
EslamHiko f7fc490
test: update snapshot
EslamHiko bc68f10
test: spread argv
EslamHiko d669b69
Merge branch 'master' into open-object
EslamHiko eaf15d2
test: remove error checks & use toBeCalledWith instead
EslamHiko a69a9e3
test: return logMock error checks
EslamHiko f5a0129
test: remove unnecessary lines
EslamHiko 5c8eac3
Merge branch 'master' into open-object
EslamHiko f1eef86
test: update success & failure types for open option
EslamHiko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ describe('runOpen util', () => { | |
|
||
it('on specify URL', () => { | ||
return runOpen('https://example.com', {}, console).then(() => { | ||
expect(opn).toBeCalledWith('https://example.com', { wait: false }); | ||
|
||
expect(opn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"https://example.com", | ||
|
@@ -34,6 +36,10 @@ describe('runOpen util', () => { | |
{ openPage: '/index.html' }, | ||
console | ||
).then(() => { | ||
expect(opn).toBeCalledWith('https://example.com/index.html', { | ||
wait: false, | ||
}); | ||
|
||
expect(opn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"https://example.com/index.html", | ||
|
@@ -51,6 +57,10 @@ describe('runOpen util', () => { | |
{ openPage: ['/index.html'] }, | ||
console | ||
).then(() => { | ||
expect(opn).toBeCalledWith('https://example.com/index.html', { | ||
wait: false, | ||
}); | ||
|
||
expect(opn.mock.calls[0]).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
@@ -61,6 +71,13 @@ describe('runOpen util', () => { | |
{ openPage: ['/index.html', '/index2.html'] }, | ||
console | ||
).then(() => { | ||
expect(opn).toBeCalledWith('https://example.com/index.html', { | ||
wait: false, | ||
}); | ||
expect(opn).toBeCalledWith('https://example.com/index2.html', { | ||
wait: false, | ||
}); | ||
|
||
expect(opn.mock.calls[0]).toMatchSnapshot(); | ||
expect(opn.mock.calls[1]).toMatchSnapshot(); | ||
}); | ||
|
@@ -72,6 +89,11 @@ describe('runOpen util', () => { | |
{ open: 'Google Chrome' }, | ||
console | ||
).then(() => { | ||
expect(opn).toBeCalledWith('https://example.com', { | ||
app: 'Google Chrome', | ||
wait: false, | ||
}); | ||
|
||
expect(opn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"https://example.com", | ||
|
@@ -90,6 +112,11 @@ describe('runOpen util', () => { | |
{ open: 'Google Chrome', openPage: '/index.html' }, | ||
console | ||
).then(() => { | ||
expect(opn).toBeCalledWith('https://example.com/index.html', { | ||
app: 'Google Chrome', | ||
wait: false, | ||
}); | ||
|
||
expect(opn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"https://example.com/index.html", | ||
|
@@ -108,6 +135,11 @@ describe('runOpen util', () => { | |
{ open: 'Google Chrome', openPage: 'https://example2.com' }, | ||
console | ||
).then(() => { | ||
expect(opn).toBeCalledWith('https://example2.com', { | ||
app: 'Google Chrome', | ||
wait: false, | ||
}); | ||
|
||
expect(opn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"https://example2.com", | ||
|
@@ -126,6 +158,10 @@ describe('runOpen util', () => { | |
{ open: 'Google Chrome', openPage: 'http://example2.com' }, | ||
console | ||
).then(() => { | ||
expect(opn).toBeCalledWith('http://example2.com', { | ||
app: 'Google Chrome', | ||
wait: false, | ||
}); | ||
expect(opn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"http://example2.com", | ||
|
@@ -148,6 +184,14 @@ describe('runOpen util', () => { | |
}, | ||
console | ||
).then(() => { | ||
expect(opn).toBeCalledWith('https://example2.com', { | ||
app: 'Google Chrome', | ||
wait: false, | ||
}); | ||
expect(opn).toBeCalledWith('https://example3.com', { | ||
app: 'Google Chrome', | ||
wait: false, | ||
}); | ||
expect(opn.mock.calls[0]).toMatchSnapshot(); | ||
expect(opn.mock.calls[1]).toMatchSnapshot(); | ||
}); | ||
|
@@ -162,6 +206,15 @@ describe('runOpen util', () => { | |
}, | ||
console | ||
).then(() => { | ||
expect(opn).toBeCalledWith('https://example.com/index.html', { | ||
app: 'Google Chrome', | ||
wait: false, | ||
}); | ||
expect(opn).toBeCalledWith('https://example2.com', { | ||
app: 'Google Chrome', | ||
wait: false, | ||
}); | ||
|
||
expect(opn.mock.calls[0]).toMatchSnapshot(); | ||
expect(opn.mock.calls[1]).toMatchSnapshot(); | ||
}); | ||
|
@@ -178,11 +231,10 @@ describe('runOpen util', () => { | |
logMock.warn.mockClear(); | ||
}); | ||
|
||
it('on specify URL and log error', () => { | ||
it('on specify URL', () => { | ||
return runOpen('https://example.com', {}, logMock).then(() => { | ||
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot( | ||
`"Unable to open \\"https://example.com\\" in browser. If you are running in a headless environment, please do not use the --open flag"` | ||
); | ||
expect(opn).toBeCalledWith('https://example.com', { wait: false }); | ||
|
||
expect(opn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"https://example.com", | ||
|
@@ -194,15 +246,16 @@ describe('runOpen util', () => { | |
}); | ||
}); | ||
|
||
it('on specify URL with page and log error', () => { | ||
it('on specify URL with page', () => { | ||
return runOpen( | ||
'https://example.com', | ||
{ openPage: '/index.html' }, | ||
logMock | ||
).then(() => { | ||
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot( | ||
`"Unable to open \\"https://example.com/index.html\\" in browser. If you are running in a headless environment, please do not use the --open flag"` | ||
); | ||
expect(opn).toBeCalledWith('https://example.com/index.html', { | ||
wait: false, | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's return warn check ( |
||
expect(opn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"https://example.com/index.html", | ||
|
@@ -214,15 +267,17 @@ describe('runOpen util', () => { | |
}); | ||
}); | ||
|
||
it('on specify URL in Google Chrome and log error', () => { | ||
it('on specify URL in Google Chrome', () => { | ||
return runOpen( | ||
'https://example.com', | ||
{ open: 'Google Chrome' }, | ||
logMock | ||
).then(() => { | ||
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot( | ||
`"Unable to open \\"https://example.com\\" in browser: \\"Google Chrome\\". If you are running in a headless environment, please do not use the --open flag"` | ||
); | ||
expect(opn).toBeCalledWith('https://example.com', { | ||
app: 'Google Chrome', | ||
wait: false, | ||
}); | ||
|
||
expect(opn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"https://example.com", | ||
|
@@ -241,9 +296,11 @@ describe('runOpen util', () => { | |
{ open: 'Google Chrome', openPage: '/index.html' }, | ||
logMock | ||
).then(() => { | ||
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot( | ||
`"Unable to open \\"https://example.com/index.html\\" in browser: \\"Google Chrome\\". If you are running in a headless environment, please do not use the --open flag"` | ||
); | ||
expect(opn).toBeCalledWith('https://example.com/index.html', { | ||
app: 'Google Chrome', | ||
wait: false, | ||
}); | ||
|
||
expect(opn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"https://example.com/index.html", | ||
|
@@ -255,5 +312,32 @@ describe('runOpen util', () => { | |
`); | ||
}); | ||
}); | ||
|
||
it('on specify URL with page in Google Chrome incognito mode and log error ', () => { | ||
return runOpen( | ||
'https://example.com', | ||
{ | ||
open: { app: ['Google Chrome', '--incognito'] }, | ||
openPage: '/index.html', | ||
}, | ||
logMock | ||
).then(() => { | ||
expect(opn).toBeCalledWith('https://example.com/index.html', { | ||
app: ['Google Chrome', '--incognito'], | ||
}); | ||
|
||
expect(opn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"https://example.com/index.html", | ||
Object { | ||
"app": Array [ | ||
"Google Chrome", | ||
"--incognito", | ||
], | ||
}, | ||
] | ||
`); | ||
}); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need these lines.