diff options
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 |