Skip to content

Commit 131782d

Browse files
author
Emmanouil Konstantinidis
committed
Test repository component
1 parent 0e2c724 commit 131782d

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"src/js/actions/actions.js": true,
6767
"src/js/components/navigation.js": true,
6868
"src/js/components/notifications.js": true,
69+
"src/js/components/repository.js": true,
6970
"src/js/components/footer.js": true,
7071
"src/js/stores/auth.js": true,
7172
"src/js/stores/notifications.js": true

src/js/__tests__/components/notifications.js

Lines changed: 1 addition & 1 deletion
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');
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/* global jest, describe, beforeEach, it, expect */
2+
3+
jest.dontMock('reflux');
4+
jest.dontMock('../../actions/actions.js');
5+
jest.dontMock('../../utils/api-requests');
6+
jest.dontMock('../../components/repository.js');
7+
jest.dontMock('../../stores/auth.js');
8+
jest.dontMock('../../stores/notifications.js');
9+
10+
var React = require('react/addons');
11+
var TestUtils = React.addons.TestUtils;
12+
13+
describe('Test for Repository Component', function () {
14+
15+
var Actions, Repository;
16+
17+
beforeEach(function () {
18+
// Mock Electron's window.require
19+
// and remote.require('shell')
20+
window.require = function () {
21+
return {
22+
require: function () {
23+
return {
24+
openExternal: function () {
25+
return {};
26+
}
27+
};
28+
}
29+
};
30+
};
31+
32+
// Mock localStorage
33+
window.localStorage = {
34+
item: false,
35+
getItem: function () {
36+
return this.item;
37+
}
38+
};
39+
40+
Actions = require('../../actions/actions.js');
41+
Repository = require('../../components/repository.js');
42+
});
43+
44+
it('Should render the Repository component', function () {
45+
46+
var repoDetails = [{
47+
'repository': {
48+
'full_name': 'ekonstantinidis/gitify',
49+
'owner': {
50+
'avatar_url': 'http://avatar.url'
51+
}
52+
},
53+
'subject': {
54+
'type': 'Issue'
55+
}
56+
}];
57+
58+
var instance = TestUtils.renderIntoDocument(
59+
<Repository
60+
repo={repoDetails}
61+
repoName='ekonstantinidis/gitify'
62+
key='ekonstantinidis/gitify' />
63+
);
64+
65+
expect(instance.props.repo[0].repository.full_name).toBe('ekonstantinidis/gitify');
66+
expect(instance.getAvatar).toBeDefined();
67+
expect(instance.openBrowser).toBeDefined();
68+
69+
// Get Avatar
70+
var avatar = instance.getAvatar();
71+
expect(avatar).toBe('http://avatar.url');
72+
73+
// Open Browser
74+
instance.openBrowser();
75+
76+
});
77+
78+
});

0 commit comments

Comments
 (0)