diff options
Diffstat (limited to 'js/tests/unit/service/ItemResourceSpec.js')
-rw-r--r-- | js/tests/unit/service/ItemResourceSpec.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/js/tests/unit/service/ItemResourceSpec.js b/js/tests/unit/service/ItemResourceSpec.js index 50454d41a..f93d92caa 100644 --- a/js/tests/unit/service/ItemResourceSpec.js +++ b/js/tests/unit/service/ItemResourceSpec.js @@ -14,6 +14,7 @@ describe('ItemResource', () => { beforeEach(module('News', ($provide) => { $provide.value('BASE_URL', 'base'); + $provide.constant('ITEM_BATCH_SIZE', 5); })); beforeEach(inject(($httpBackend) => { @@ -59,6 +60,34 @@ describe('ItemResource', () => { })); + it ('should mark multiple item as read', inject((ItemResource) => { + http.expectPOST('base/items/read/multiple', { + itemIds: [3, 4] + }).respond(200, {}); + + ItemResource.receive([ + { + id: 3, + feedId: 4, + unread: true + }, + { + id: 4, + feedId: 3, + unread: true + } + ], 'items'); + + ItemResource.markItemsRead([3, 4]); + + http.flush(); + + expect(ItemResource.get(3).unread).toBe(false); + expect(ItemResource.get(4).unread).toBe(false); + })); + + + it ('should star item', inject((ItemResource) => { http.expectPOST('base/items/4/a/star', {isStarred: true}) .respond(200, {}); @@ -169,6 +198,34 @@ describe('ItemResource', () => { })); + it ('should auto page', inject((ItemResource) => { + http.expectGET('base/items?id=4&limit=5&offset=3&type=3') + .respond(200, {}); + + ItemResource.receive([ + { + id: 3, + feedId: 4, + unread: true + }, + { + id: 4, + feedId: 3, + unread: true + }, + { + id: 5, + feedId: 4, + unread: true + } + ], 'items'); + + ItemResource.autoPage(3, 4); + + http.flush(); + })); + + afterEach(() => { http.verifyNoOutstandingExpectation(); http.verifyNoOutstandingRequest(); |