diff options
Diffstat (limited to 'js/tests/unit')
-rw-r--r-- | js/tests/unit/controller/ContentControllerSpec.js | 6 | ||||
-rw-r--r-- | js/tests/unit/service/ItemResourceSpec.js | 69 |
2 files changed, 69 insertions, 6 deletions
diff --git a/js/tests/unit/controller/ContentControllerSpec.js b/js/tests/unit/controller/ContentControllerSpec.js index a157cd2d1..515265bc3 100644 --- a/js/tests/unit/controller/ContentControllerSpec.js +++ b/js/tests/unit/controller/ContentControllerSpec.js @@ -270,7 +270,8 @@ describe('ContentController', function () { it('should not autopage if less than 0 elements', inject(function ( - $controller, ItemResource, Publisher) { + $controller, ItemResource, Publisher, SettingsResource) { + SettingsResource.set('oldestFirst', true); var $route = { current: { @@ -305,6 +306,7 @@ describe('ContentController', function () { $route: $route, Publisher: Publisher, ItemResource: ItemResource, + SettingsResource: SettingsResource, data: {}, }); @@ -314,7 +316,7 @@ describe('ContentController', function () { expect(ctrl.autoPagingEnabled()).toBe(false); - expect(ItemResource.autoPage).toHaveBeenCalledWith(3, 2); + expect(ItemResource.autoPage).toHaveBeenCalledWith(3, 2, true); })); diff --git a/js/tests/unit/service/ItemResourceSpec.js b/js/tests/unit/service/ItemResourceSpec.js index 4040536ef..7b7df64fb 100644 --- a/js/tests/unit/service/ItemResourceSpec.js +++ b/js/tests/unit/service/ItemResourceSpec.js @@ -209,8 +209,9 @@ describe('ItemResource', function () { })); - it ('should auto page', inject(function (ItemResource) { - http.expectGET('base/items?id=4&limit=5&offset=3&type=3') + it ('should auto page newest first', inject(function (ItemResource) { + http.expectGET( + 'base/items?id=4&limit=5&offset=3&oldestFirst=false&type=3') .respond(200, {}); ItemResource.receive([ @@ -220,21 +221,81 @@ describe('ItemResource', function () { unread: true }, { - id: 4, + id: 5, feedId: 3, unread: true }, { + id: 4, + feedId: 4, + unread: true + } + ], 'items'); + + ItemResource.autoPage(3, 4, false); + + http.flush(); + })); + + + it ('should auto page oldest first', inject(function (ItemResource) { + http.expectGET( + 'base/items?id=4&limit=5&offset=5&oldestFirst=true&type=3') + .respond(200, {}); + + ItemResource.receive([ + { + id: 3, + feedId: 4, + unread: true + }, + { id: 5, + feedId: 3, + unread: true + }, + { + id: 4, feedId: 4, unread: true } ], 'items'); - ItemResource.autoPage(3, 4); + ItemResource.autoPage(3, 4, true); http.flush(); })); + + it ('should clear all state', inject(function (ItemResource) { + ItemResource.receive([ + { + id: 3, + feedId: 4, + unread: true + }, + { + id: 5, + feedId: 3, + unread: true + }, + { + id: 4, + feedId: 4, + unread: true + } + ], 'items'); + ItemResource.receive(5, 'newestItemId'); + ItemResource.receive(4, 'starred'); + + ItemResource.clear(); + + expect(ItemResource.size()).toBe(0); + expect(ItemResource.highestId).toBe(0); + expect(ItemResource.lowestId).toBe(0); + expect(ItemResource.starredCount).toBe(0); + })); + + });
\ No newline at end of file |