Skip to content

Commit 0a9f228

Browse files
author
Emmanouil Konstantinidis
committed
Coverage 100%
1 parent 4190d34 commit 0a9f228

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

src/js/__tests__/components/repository.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('Test for Repository Component', function () {
7878

7979
});
8080

81-
it('Should mark a repo as read - succsfully', function () {
81+
it('Should mark a repo as read - successfully', function () {
8282

8383
var repoDetails = [{
8484
'repository': {
@@ -115,4 +115,43 @@ describe('Test for Repository Component', function () {
115115

116116
});
117117

118+
it('Should mark a repo as read - fail', function () {
119+
120+
var repoDetails = [{
121+
'repository': {
122+
'name': 'gitify',
123+
'full_name': 'ekonstantinidis/gitify',
124+
'owner': {
125+
'login': 'ekonstantinidis',
126+
'avatar_url': 'http://avatar.url'
127+
}
128+
},
129+
'subject': {
130+
'type': 'Issue'
131+
}
132+
}];
133+
134+
var instance = TestUtils.renderIntoDocument(
135+
<Repository
136+
repo={repoDetails}
137+
repoName='ekonstantinidis/gitify'
138+
key='ekonstantinidis/gitify' />
139+
);
140+
141+
expect(instance.state.isRead).toBeFalsy();
142+
expect(instance.state.errors).toBeFalsy();
143+
expect(instance.markRepoAsRead).toBeDefined();
144+
145+
var superagent = require('superagent');
146+
superagent.__setResponse(400, false);
147+
148+
// Mark Repo as Read
149+
instance.markRepoAsRead();
150+
jest.runAllTimers();
151+
152+
expect(instance.state.isRead).toBeFalsy();
153+
expect(instance.state.errors).toBeTruthy();
154+
155+
});
156+
118157
});

0 commit comments

Comments
 (0)