diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-27 12:26:04 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-27 12:26:04 +0100 |
commit | 02ae36eba33a5e0957defd4619d337bfdd0c178f (patch) | |
tree | d80f58cdf9eb774d00fc5fc322bf0750b644dab2 /js/tests/services/models/itemmodelSpec.coffee | |
parent | 89a1713f062cc78b727c6240a91408d91611dbab (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/services/models/itemmodelSpec.coffee')
-rw-r--r-- | js/tests/services/models/itemmodelSpec.coffee | 29 |
1 files changed, 28 insertions, 1 deletions
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 |