Skip to content

Commit 89750d8

Browse files
author
Emmanouil Konstantinidis
committed
Mock browser window
1 parent 759ceea commit 89750d8

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/js/__tests__/components/login.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global jest, describe, beforeEach, it, expect, spyOn */
1+
/* global jest, describe, beforeEach, it, expect */
22

33
jest.dontMock('reflux');
44
jest.dontMock('../../actions/actions.js');
@@ -16,10 +16,26 @@ describe('Test for Login Component', function () {
1616
beforeEach(function () {
1717
// Mock Electron's window.require
1818
// and remote.ipc
19+
var browserWindow = function () {
20+
return {
21+
loadUrl: function () {
22+
return;
23+
},
24+
webContents: {
25+
on: function () {
26+
return;
27+
}
28+
},
29+
on: function () {
30+
return;
31+
}
32+
};
33+
};
34+
1935
window.require = function () {
2036
return {
2137
require: function () {
22-
return;
38+
return browserWindow;
2339
},
2440
sendChannel: function () {
2541
return;
@@ -76,4 +92,13 @@ describe('Test for Login Component', function () {
7692

7793
});
7894

95+
it('Should open the authWindow', function () {
96+
97+
var instance = TestUtils.renderIntoDocument(<Login />);
98+
expect(instance.authGithub).toBeDefined();
99+
100+
instance.authGithub();
101+
102+
});
103+
79104
});

0 commit comments

Comments
 (0)