diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-04 15:23:58 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-04 15:23:58 +0200 |
commit | b723c12e4c3e0039d9785861d4ad204fd899ac52 (patch) | |
tree | e7adc950dd113d3efffdca25c0bc77278edebb0d /js/tests/services/models/itemmodelSpec.coffee | |
parent | 180b36f9b234e68c9ab314d67b23f13548790c6c (diff) |
improved and cleaned up js unittests
Diffstat (limited to 'js/tests/services/models/itemmodelSpec.coffee')
-rw-r--r-- | js/tests/services/models/itemmodelSpec.coffee | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/js/tests/services/models/itemmodelSpec.coffee b/js/tests/services/models/itemmodelSpec.coffee index a163632eb..ef6b535c4 100644 --- a/js/tests/services/models/itemmodelSpec.coffee +++ b/js/tests/services/models/itemmodelSpec.coffee @@ -20,90 +20,87 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -describe '_ItemModel', -> - +describe 'ItemModel', -> beforeEach module 'News' - beforeEach inject (@_ItemModel, @_Model) => - @model = new @_ItemModel() + beforeEach inject (@ItemModel, @_Model) => it 'should extend model', => - expect(new @_ItemModel instanceof @_Model).toBeTruthy() + expect(@ItemModel instanceof @_Model).toBeTruthy() it 'should also update items with the same feed id and guidhash', => item1 = {id: 4, guidHash: 'abc', feedId: 3} - @model.add(item1) + @ItemModel.add(item1) - expect(@model.getById(4)).toBe(item1) + expect(@ItemModel.getById(4)).toBe(item1) # normal id update item2 = {id: 4, guidHash: 'abc', feedId: 4} - @model.add(item2) - expect(@model.size()).toBe(1) + @ItemModel.add(item2) + expect(@ItemModel.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) + @ItemModel.add(item3) + expect(@ItemModel.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) + @ItemModel.add(item4) + expect(@ItemModel.getById(3).guidHash).toBe(item4.guidHash) + expect(@ItemModel.getById(3).feedId).toBe(item4.feedId) + expect(@ItemModel.getById(3).id).toBe(item4.id) + expect(@ItemModel.getById(5)).toBe(undefined) + expect(@ItemModel.size()).toBe(2) it 'should also remove the feed from the urlHash cache when its removed', => - @model = new @_ItemModel() item = {id: 4, guidHash: 'abc', feedId: 3} - @model.add(item) + @ItemModel.add(item) - expect(@model.getById(4)).toBe(item) - expect(@model.getByGuidHashAndFeedId('abc', 3)).toBe(item) + expect(@ItemModel.getById(4)).toBe(item) + expect(@ItemModel.getByGuidHashAndFeedId('abc', 3)).toBe(item) - @model.removeById(4) - expect(@model.getByGuidHashAndFeedId('abc', 3)).toBe(undefined) + @ItemModel.removeById(4) + expect(@ItemModel.getByGuidHashAndFeedId('abc', 3)).toBe(undefined) it 'should bind the correct isRead() method to the item', => item = {id: 3, guidHash: 'abc', feedId: 6, status: 16} - @model.add(item) + @ItemModel.add(item) item.setRead() - expect(@model.getById(3).isRead()).toBe(true) + expect(@ItemModel.getById(3).isRead()).toBe(true) it 'should bind the correct set unread method to the item', => item = {id: 3, guidHash: 'abc', feedId: 6, status: 16} - @model.add(item) + @ItemModel.add(item) item.setUnread() - expect(@model.getById(3).isRead()).toBe(false) + expect(@ItemModel.getById(3).isRead()).toBe(false) it 'should bind the correct set starred method to the item', => item = {id: 3, guidHash: 'abc', feedId: 6, status: 16} - @model.add(item) + @ItemModel.add(item) item.setStarred() - expect(@model.getById(3).isStarred()).toBe(true) + expect(@ItemModel.getById(3).isStarred()).toBe(true) it 'should bind the correct set unstarred method to the item', => item = {id: 3, guidHash: 'abc', feedId: 6, status: 16} - @model.add(item) + @ItemModel.add(item) item.setUnstarred() - expect(@model.getById(3).isStarred()).toBe(false) + expect(@ItemModel.getById(3).isStarred()).toBe(false)
\ No newline at end of file |