Skip to content

Commit df5412e

Browse files
author
Emmanouil Konstantinidis
committed
Complete tests for 'notification' component
1 parent 5c3309c commit df5412e

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

src/js/__tests__/components/notification.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,60 @@ describe('Test for Notification Component', function () {
131131

132132
});
133133

134+
it('Should mark a notification as read succesfully', function () {
135+
136+
var notification = {
137+
'id': '123123123',
138+
'repository': {
139+
'full_name': 'ekonstantinidis/gitify',
140+
'owner': {
141+
'avatar_url': 'http://avatar.url'
142+
}
143+
},
144+
'subject': {
145+
'type': 'Issue',
146+
'url': 'http://www.github.com/ekonstantinidis/gitify/pulls/26/'
147+
}
148+
};
149+
150+
var instance = TestUtils.renderIntoDocument(
151+
<SingleNotification
152+
notification={notification}
153+
key={notification.id} />);
154+
155+
var superagent = require('superagent');
156+
superagent.__setResponse(200, 'ok', {}, false);
157+
158+
instance.markAsRead();
159+
160+
});
161+
162+
it('Should fail to mark a notification as read succesfully', function () {
163+
164+
var notification = {
165+
'id': '123123123',
166+
'repository': {
167+
'full_name': 'ekonstantinidis/gitify',
168+
'owner': {
169+
'avatar_url': 'http://avatar.url'
170+
}
171+
},
172+
'subject': {
173+
'type': 'Issue',
174+
'url': 'http://www.github.com/ekonstantinidis/gitify/pulls/26/'
175+
}
176+
};
177+
178+
var instance = TestUtils.renderIntoDocument(
179+
<SingleNotification
180+
notification={notification}
181+
key={notification.id} />);
182+
183+
var superagent = require('superagent');
184+
superagent.__setResponse(400, 'notOk', {}, false);
185+
186+
instance.markAsRead();
187+
188+
});
189+
134190
});

src/js/components/notification.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var Notification = React.createClass({
3737
});
3838
} else {
3939
// Error - Show messages.
40-
console.log(err);
40+
// Show appropriate message
4141
}
4242
});
4343
},

0 commit comments

Comments
 (0)