summaryrefslogtreecommitdiffstats
path: root/js/tests
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-22 02:40:44 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-22 02:40:44 +0200
commit23246ea3987d8a60d3ea344ca93d209d082c3337 (patch)
treee8a63fcd0e3cfdd02c3ab78a2001413d2e83bfc1 /js/tests
parent2b4da592f1c8a2210f9ba49a9e24eb2056e5d4a8 (diff)
add keep unread, read, read feed and starring
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/service/ItemResourceSpec.js99
1 files changed, 98 insertions, 1 deletions
diff --git a/js/tests/unit/service/ItemResourceSpec.js b/js/tests/unit/service/ItemResourceSpec.js
index 8d0f1864e..49989472f 100644
--- a/js/tests/unit/service/ItemResourceSpec.js
+++ b/js/tests/unit/service/ItemResourceSpec.js
@@ -10,10 +10,16 @@
describe('ItemResource', () => {
'use strict';
+ let http;
+
beforeEach(module('News', ($provide) => {
$provide.value('BASE_URL', 'base');
}));
+ beforeEach(inject(($httpBackend) => {
+ http = $httpBackend;
+ }));
+
it('should receive the newestItemId', inject((ItemResource) => {
ItemResource.receive(3, 'newestItemId');
@@ -43,7 +49,83 @@ describe('ItemResource', () => {
}));
+ it ('should keep item unread', inject((ItemResource) => {
+ http.expectPOST('base/items/3/read', {isRead: false}).respond(200, {});
+
+ ItemResource.receive([
+ {
+ id: 3,
+ feedId: 4,
+ unread: false
+ },
+ {
+ id: 4,
+ feedId: 3,
+ unread: false
+ }
+ ], 'items');
+
+ ItemResource.keepUnread(3);
+
+ http.flush();
+
+ expect(ItemResource.get(3).keepUnread).toBe(true);
+ expect(ItemResource.get(3).unread).toBe(true);
+ }));
+
+
it ('should mark item as read', inject((ItemResource) => {
+ http.expectPOST('base/items/3/read', {isRead: true}).respond(200, {});
+
+ ItemResource.receive([
+ {
+ id: 3,
+ feedId: 4,
+ unread: true
+ },
+ {
+ id: 4,
+ feedId: 3,
+ unread: true
+ }
+ ], 'items');
+
+ ItemResource.read(3);
+
+ http.flush();
+
+ expect(ItemResource.get(3).unread).toBe(false);
+ }));
+
+
+ it ('should star item', inject((ItemResource) => {
+ http.expectPOST('base/items/4/a/star', {isStarred: true}).respond(200, {});
+
+ ItemResource.receive([
+ {
+ id: 3,
+ feedId: 4,
+ starred: false,
+ guidHash: 'a'
+ },
+ {
+ id: 4,
+ feedId: 3,
+ starred: false
+ }
+ ], 'items');
+
+ ItemResource.star(3);
+
+ http.flush();
+
+ expect(ItemResource.get(3).starred).toBe(true);
+ }));
+
+
+ it ('should mark feed as read', inject((ItemResource) => {
+ http.expectPOST('base/feeds/4/read').respond(200, {});
+
ItemResource.receive([
{
id: 3,
@@ -54,12 +136,27 @@ describe('ItemResource', () => {
id: 4,
feedId: 3,
unread: true
+ },
+ {
+ id: 5,
+ feedId: 4,
+ unread: true
}
], 'items');
- ItemResource.markRead(3);
+ ItemResource.readFeed(4);
+
+ http.flush();
expect(ItemResource.get(3).unread).toBe(false);
+ expect(ItemResource.get(5).unread).toBe(false);
}));
+
+ afterEach(() => {
+ http.verifyNoOutstandingExpectation();
+ http.verifyNoOutstandingRequest();
+ });
+
+
}); \ No newline at end of file