summaryrefslogtreecommitdiffstats
path: root/js/tests
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-03-27 12:26:04 +0100
committerBernhard Posselt <nukeawhale@gmail.com>2013-03-27 12:26:04 +0100
commit02ae36eba33a5e0957defd4619d337bfdd0c178f (patch)
treed80f58cdf9eb774d00fc5fc322bf0750b644dab2 /js/tests
parent89a1713f062cc78b727c6240a91408d91611dbab (diff)
fixed mark all unread serverside (was missing highestitemid, dont use lastmodified to compare for new versions but use the highest item id. if items are updated and the guidHash and feedId are the same then it will be deleted and newly inserted to make the lastmodified feasable
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/controllers/feedcontrollerSpec.coffee8
-rw-r--r--js/tests/services/models/itemmodelSpec.coffee29
2 files changed, 32 insertions, 5 deletions
diff --git a/js/tests/controllers/feedcontrollerSpec.coffee b/js/tests/controllers/feedcontrollerSpec.coffee
index 8ef621030..6ec75e920 100644
--- a/js/tests/controllers/feedcontrollerSpec.coffee
+++ b/js/tests/controllers/feedcontrollerSpec.coffee
@@ -152,7 +152,7 @@ describe '_FeedController', ->
@ActiveFeed.handle({id: 3, type: 3})
@scope.loadFeed(3, 3)
- expect(@persistence.getItems).toHaveBeenCalledWith(3, 3, 0, null, 323)
+ expect(@persistence.getItems).toHaveBeenCalledWith(3, 3, 0, null, 6)
it 'should send a get all items query when feed changed', =>
@@ -232,9 +232,9 @@ describe '_FeedController', ->
it 'should mark feed as read', =>
@persistence.setFeedRead = jasmine.createSpy('setFeedRead')
@FeedModel.add({id: 5, unreadCount:2, folderId: 2})
- @ItemModel.add({id: 6})
- @ItemModel.add({id: 3})
- @ItemModel.add({id: 2})
+ @ItemModel.add({id: 6, feedId: 5, guidHash: 'a'})
+ @ItemModel.add({id: 3, feedId: 5, guidHash: 'a1'})
+ @ItemModel.add({id: 2, feedId: 5, guidHash: 'a2'})
@scope.markAllRead(@FeedType.Feed, 5)
expect(@persistence.setFeedRead).toHaveBeenCalledWith(5, 6)
diff --git a/js/tests/services/models/itemmodelSpec.coffee b/js/tests/services/models/itemmodelSpec.coffee
index 061f84f01..7d929b223 100644
--- a/js/tests/services/models/itemmodelSpec.coffee
+++ b/js/tests/services/models/itemmodelSpec.coffee
@@ -29,4 +29,31 @@ describe '_ItemModel', ->
it 'should extend model', =>
- expect(new @_ItemModel instanceof @_Model).toBeTruthy() \ No newline at end of file
+ expect(new @_ItemModel instanceof @_Model).toBeTruthy()
+
+
+ it 'should also update items with the same feed id and guidhash', =>
+ model = new @_ItemModel()
+ item1 = {id: 4, guidHash: 'abc', feedId: 3}
+ model.add(item1)
+
+ expect(model.getById(4)).toBe(item1)
+
+ # normal id update
+ item2 = {id: 4, guidHash: 'abc', feedId: 4}
+ model.add(item2)
+ expect(model.size()).toBe(1)
+
+ # new feeds should be added normally if different
+ item3 = {id: 5, guidHash: 'abc', feedId: 6}
+ model.add(item3)
+ expect(model.size()).toBe(2)
+
+ # feed should be updated when guidhash and feedid the same
+ item4 = {id: 3, guidHash: 'abc', feedId: 6}
+ model.add(item4)
+ expect(model.getById(3).guidHash).toBe(item4.guidHash)
+ expect(model.getById(3).feedId).toBe(item4.feedId)
+ expect(model.getById(3).id).toBe(item4.id)
+ expect(model.getById(5)).toBe(undefined)
+ expect(model.size()).toBe(2) \ No newline at end of file