summaryrefslogtreecommitdiffstats
path: root/js/tests
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-05 14:27:14 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-05 14:27:14 +0200
commit685ff350eb6c91fd8f48d31a4ba6a815d5f6e403 (patch)
tree0ee3336fc8f0ea60bf71275d3be4f9faea5784db /js/tests
parent1df9491ac0568ece09d4836b6296346cf51c75fa (diff)
reduce unreadcount instantly when marking as read, fixes #7
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/services/bl/itemblSpec.coffee31
1 files changed, 27 insertions, 4 deletions
diff --git a/js/tests/services/bl/itemblSpec.coffee b/js/tests/services/bl/itemblSpec.coffee
index 01b02bfb2..cbaef5488 100644
--- a/js/tests/services/bl/itemblSpec.coffee
+++ b/js/tests/services/bl/itemblSpec.coffee
@@ -32,6 +32,8 @@ describe 'ItemBl', ->
beforeEach inject (@ItemModel, @ItemBl, @StatusFlag, @ActiveFeed
@FeedType, @FeedModel, @StarredBl) =>
+ @item1 = {id: 5, title: 'hi', unreadCount:134, urlHash: 'a3', folderId: 3}
+ @FeedModel.add(@item1)
it 'should return all items', =>
@@ -68,9 +70,6 @@ describe 'ItemBl', ->
it 'should return the correct feed title', =>
- item1 = {id: 5, title: 'hi', unreadCount:134, urlHash: 'a3', folderId: 3}
- @FeedModel.add(item1)
-
item2 = {id: 2, feedId: 5, guidHash: 'a3'}
@ItemModel.add(item2)
@@ -131,7 +130,7 @@ describe 'ItemBl', ->
it 'should toggle an item as kept unread', =>
@persistence.unreadItem = jasmine.createSpy('unread item')
-
+
item = {id: 2, feedId: 5, guidHash: 'a3', status: 0}
@ItemModel.add(item)
@@ -168,3 +167,27 @@ describe 'ItemBl', ->
expect(item.isRead()).toBe(false)
expect(@persistence.unreadItem).toHaveBeenCalledWith(2)
+
+
+ it 'should lower the unread count of a feed when its items get read', =>
+ @persistence.readItem = jasmine.createSpy('read item')
+
+ item = {id: 2, feedId: 5, guidHash: 'a3', status: 0}
+ @ItemModel.add(item)
+ item.setUnread()
+
+ @ItemBl.setRead(2)
+
+ expect(@item1.unreadCount).toBe(133)
+
+
+ it 'should increase the unread count of a feed when its items get unread', =>
+ @persistence.unreadItem = jasmine.createSpy('unread item')
+
+ item = {id: 2, feedId: 5, guidHash: 'a3', status: 0}
+ @ItemModel.add(item)
+ item.setRead()
+
+ @ItemBl.setUnread(2)
+
+ expect(@item1.unreadCount).toBe(135) \ No newline at end of file