diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-04 19:58:51 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-04 19:59:06 +0200 |
commit | 346346e01c5c61e61b522520248de90e0ede3f17 (patch) | |
tree | 9d38239274db7e26eac9eda9f1853113e655857b /js/tests/services/bl/feedblSpec.coffee | |
parent | 2d8b635796ba117619063792b0a00c50dc91d2a6 (diff) |
added most of the bl functionality
Diffstat (limited to 'js/tests/services/bl/feedblSpec.coffee')
-rw-r--r-- | js/tests/services/bl/feedblSpec.coffee | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/js/tests/services/bl/feedblSpec.coffee b/js/tests/services/bl/feedblSpec.coffee index 602e93909..241ba20f5 100644 --- a/js/tests/services/bl/feedblSpec.coffee +++ b/js/tests/services/bl/feedblSpec.coffee @@ -27,11 +27,23 @@ describe 'FeedBl', -> beforeEach => angular.module('News').factory 'Persistence', => - @persistence = {} + @setFeedReadSpy = jasmine.createSpy('setFeedRead') + @persistence = { + setFeedRead: @setFeedReadSpy + } beforeEach inject (@FeedBl, @FeedModel, @ItemModel) => + it 'should delete feeds', => + @FeedModel.removeById = jasmine.createSpy('remove') + @persistence.deleteFeed = jasmine.createSpy('deletequery') + @FeedBl.delete(3) + + expect(@FeedModel.removeById).toHaveBeenCalledWith(3) + expect(@persistence.deleteFeed).toHaveBeenCalledWith(3) + + it 'should return the number of unread feeds', => @FeedModel.add({id: 3, unreadCount:134, urlHash: 'a1'}) count = @FeedBl.getUnreadCount(3) @@ -63,16 +75,6 @@ describe 'FeedBl', -> expect(count).toBe(169) - it 'should delete feeds', => - @FeedModel.removeById = jasmine.createSpy('remove') - @persistence.deleteFeed = jasmine.createSpy('deletequery') - @FeedBl.delete(3) - - expect(@FeedModel.removeById).toHaveBeenCalledWith(3) - expect(@persistence.deleteFeed).toHaveBeenCalledWith(3) - - - it 'should mark feed as read', => @persistence.setFeedRead = jasmine.createSpy('setFeedRead') @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'}) @@ -83,6 +85,9 @@ describe 'FeedBl', -> expect(@persistence.setFeedRead).toHaveBeenCalledWith(5, 6) expect(@FeedModel.getById(5).unreadCount).toBe(0) + expect(@ItemModel.getById(6).isRead()).toBeTruthy() + expect(@ItemModel.getById(3).isRead()).toBeTruthy() + expect(@ItemModel.getById(2).isRead()).toBeTruthy() it 'should mark all as read', => @@ -101,6 +106,14 @@ describe 'FeedBl', -> it 'should get the correct unread count for subscribtions', => @FeedModel.add({id: 3, unreadCount:134, urlHash: 'a1'}) @FeedModel.add({id: 5, unreadCount:2, urlHash: 'a2'}) - count = @FeedBl.getUnreadCount() + count = @FeedBl.getAllUnreadCount() + + expect(count).toBe(136) + + + it 'should return the correct number of feeds', => + @FeedModel.add({id: 3, unreadCount:134, urlHash: 'a1'}) + @FeedModel.add({id: 5, unreadCount:2, urlHash: 'a2'}) + count = @FeedBl.getNumberOfFeeds() - expect(count).toBe(136)
\ No newline at end of file + expect(count).toBe(2)
\ No newline at end of file |