diff options
Diffstat (limited to 'js/tests/services')
-rw-r--r-- | js/tests/services/businesslayer/itembusinesslayerSpec.coffee | 16 | ||||
-rw-r--r-- | js/tests/services/persistenceSpec.coffee | 33 |
2 files changed, 49 insertions, 0 deletions
diff --git a/js/tests/services/businesslayer/itembusinesslayerSpec.coffee b/js/tests/services/businesslayer/itembusinesslayerSpec.coffee index 75804323d..9ac0a9e24 100644 --- a/js/tests/services/businesslayer/itembusinesslayerSpec.coffee +++ b/js/tests/services/businesslayer/itembusinesslayerSpec.coffee @@ -264,3 +264,19 @@ describe 'ItemBusinessLayer', -> expect(@persistence.getNewItems).toHaveBeenCalledWith( @FeedType.Feed, 3, 4, callback) + + + it 'should autopage the next items if there are none', => + @NewestItem.handle(13) + @persistence.getItems = jasmine.createSpy('autopage') + callback = -> + + @ItemModel.add({id: 2, guidHash: 'abc', feedId: 2, status: 16}) + @ItemModel.add({id: 3, guidHash: 'abcd', feedId: 2, status: 16}) + @ItemModel.add({id: 1, guidHash: 'abce', feedId: 2, status: 16}) + @ItemModel.add({id: 6, guidHash: 'abcf', feedId: 2, status: 16}) + + @ItemBusinessLayer.loadNext(callback) + + expect(@persistence.getItems).toHaveBeenCalledWith( + @FeedType.Feed, 3, 1, jasmine.any(Function))
\ No newline at end of file diff --git a/js/tests/services/persistenceSpec.coffee b/js/tests/services/persistenceSpec.coffee index b9250b974..323a41330 100644 --- a/js/tests/services/persistenceSpec.coffee +++ b/js/tests/services/persistenceSpec.coffee @@ -74,6 +74,37 @@ describe 'Persistence', -> expect(@req.get).toHaveBeenCalledWith('news_items', expected) + it 'should reset the autopage lock when loading a new feed', => + data = + items: [] + called = 0 + @req.get.andCallFake (route, params) -> + params.onSuccess(data) + called++ + + success = -> + @Persistence.getItems(2, 3, 4, success) + @Persistence.getItems(2, 3, 0, success) + + expect(called).toBe(2) + + + it 'should not send autopage request if reqeust returned nothing', => + data = + items: [] + called = 0 + @req.get.andCallFake (route, params) -> + params.onSuccess(data) + called++ + + success = -> + @Persistence.getItems(2, 3, 4, success) + @Persistence.getItems(2, 3, 4, success) + + expect(called).toBe(1) + + + it 'should send a load new items request', => success = -> params = @@ -446,3 +477,5 @@ describe 'Persistence', -> expect(@req.post).toHaveBeenCalledWith('news_usersettings_setcompact', expected) + + |