Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 4ab44f3

Browse files
committed
Update shell.openExternal stubs
1 parent 017f59a commit 4ab44f3

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

test/controllers/issueish-list-controller.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ describe('IssueishListController', function() {
9090

9191
it('calls shell.openExternal with specified url', async function() {
9292
const wrapper = shallow(buildApp());
93-
sinon.stub(shell, 'openExternal').callsArg(2);
93+
sinon.stub(shell, 'openExternal').callsFake(() => { });
9494

9595
await wrapper.instance().openOnGitHub(url);
9696
assert.isTrue(shell.openExternal.calledWith(url));
9797
});
9898

9999
it('fires `open-issueish-in-browser` event upon success', async function() {
100100
const wrapper = shallow(buildApp());
101-
sinon.stub(shell, 'openExternal').callsArg(2);
101+
sinon.stub(shell, 'openExternal').callsFake(() => {});
102102
sinon.stub(reporterProxy, 'addEvent');
103103

104104
await wrapper.instance().openOnGitHub(url);
@@ -109,7 +109,7 @@ describe('IssueishListController', function() {
109109

110110
it('handles error when openOnGitHub fails', async function() {
111111
const wrapper = shallow(buildApp());
112-
sinon.stub(shell, 'openExternal').callsArgWith(2, new Error('oh noes'));
112+
sinon.stub(shell, 'openExternal').throws(new Error('oh noes'));
113113
sinon.stub(reporterProxy, 'addEvent');
114114

115115
try {

test/controllers/remote-controller.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('RemoteController', function() {
5252

5353
it('increments a counter when onCreatePr is called', async function() {
5454
const wrapper = shallow(createApp());
55-
sinon.stub(shell, 'openExternal').callsArg(2);
55+
sinon.stub(shell, 'openExternal').callsFake(() => {});
5656
sinon.stub(reporterProxy, 'incrementCounter');
5757

5858
await wrapper.instance().onCreatePr();
@@ -62,7 +62,7 @@ describe('RemoteController', function() {
6262

6363
it('handles error when onCreatePr fails', async function() {
6464
const wrapper = shallow(createApp());
65-
sinon.stub(shell, 'openExternal').callsArgWith(2, new Error('oh noes'));
65+
sinon.stub(shell, 'openExternal').throws(new Error('oh noes'));
6666
sinon.stub(reporterProxy, 'incrementCounter');
6767

6868
try {

test/views/actionable-review-view.test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,39 +69,38 @@ describe('ActionableReviewView', function() {
6969
}
7070

7171
it("opens the content object's URL with 'Open on GitHub'", async function() {
72-
sinon.stub(shell, 'openExternal').callsArg(2);
72+
sinon.stub(shell, 'openExternal').callsFake(() => {});
7373

7474
const item = triggerMenu({url: 'https://github.com'}, {}).items.find(i => i.label === 'Open on GitHub');
7575
await item.click();
7676

77-
assert.isTrue(shell.openExternal.calledWith('https://github.com', {}));
77+
assert.isTrue(shell.openExternal.calledWith('https://github.com'));
7878
assert.isTrue(reporterProxy.addEvent.calledWith('open-comment-in-browser'));
7979
});
8080

8181
it("rejects the promise when 'Open on GitHub' fails", async function() {
82-
sinon.stub(shell, 'openExternal').callsArgWith(2, new Error("I don't feel like it"));
82+
sinon.stub(shell, 'openExternal').throws(new Error("I don't feel like it"));
8383

8484
const item = triggerMenu({url: 'https://github.com'}, {}).items.find(i => i.label === 'Open on GitHub');
8585
await assert.isRejected(item.click());
8686
assert.isFalse(reporterProxy.addEvent.called);
8787
});
8888

8989
it('opens a prepopulated abuse-reporting link with "Report abuse"', async function() {
90-
sinon.stub(shell, 'openExternal').callsArg(2);
90+
sinon.stub(shell, 'openExternal').callsFake(() => {});
9191

9292
const item = triggerMenu({url: 'https://github.com/a/b'}, {login: 'tyrion'})
9393
.items.find(i => i.label === 'Report abuse');
9494
await item.click();
9595

9696
assert.isTrue(shell.openExternal.calledWith(
9797
'https://github.com/contact/report-content?report=tyrion&content_url=https%3A%2F%2Fgithub.com%2Fa%2Fb',
98-
{},
9998
));
10099
assert.isTrue(reporterProxy.addEvent.calledWith('report-abuse'));
101100
});
102101

103102
it("rejects the promise when 'Report abuse' fails", async function() {
104-
sinon.stub(shell, 'openExternal').callsArgWith(2, new Error('nah'));
103+
sinon.stub(shell, 'openExternal').throws(new Error('nah'));
105104

106105
const item = triggerMenu({url: 'https://github.com/a/b'}, {login: 'tyrion'})
107106
.items.find(i => i.label === 'Report abuse');

test/views/github-dotcom-markdown.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ describe('GithubDotcomMarkdown', function() {
213213
});
214214

215215
it('records event for opening issueish in browser', async function() {
216-
sinon.stub(shell, 'openExternal').callsArg(2);
216+
sinon.stub(shell, 'openExternal').callsFake(() => {});
217217
sinon.stub(reporterProxy, 'addEvent');
218218

219219
const issueishLink = wrapper.getDOMNode().querySelector('a.issue-link');
@@ -228,7 +228,7 @@ describe('GithubDotcomMarkdown', function() {
228228
});
229229

230230
it('does not record event if opening issueish in browser fails', function() {
231-
sinon.stub(shell, 'openExternal').callsArgWith(2, new Error('oh noes'));
231+
sinon.stub(shell, 'openExternal').throws(new Error('oh noes'));
232232
sinon.stub(reporterProxy, 'addEvent');
233233

234234
// calling `handleClick` directly rather than dispatching event so that we can catch the error thrown and prevent errors in the console

0 commit comments

Comments
 (0)