diff options
Diffstat (limited to 'js/tests')
-rw-r--r-- | js/tests/services/activefeedSpec.coffee | 21 | ||||
-rw-r--r-- | js/tests/services/bl/feedblSpec.coffee | 28 | ||||
-rw-r--r-- | js/tests/services/bl/folderblSpec.coffee | 30 | ||||
-rw-r--r-- | js/tests/services/bl/itemblSpec.coffee | 13 | ||||
-rw-r--r-- | js/tests/services/feedtypeSpec.coffee | 1 | ||||
-rw-r--r-- | js/tests/services/models/feedmodelSpec.coffee | 57 | ||||
-rw-r--r-- | js/tests/services/models/foldermodelSpec.coffee | 13 | ||||
-rw-r--r-- | js/tests/services/models/itemmodelSpec.coffee | 59 | ||||
-rw-r--r-- | js/tests/services/opmlparserSpec.coffee | 10 | ||||
-rw-r--r-- | js/tests/services/showallSpec.coffee | 26 | ||||
-rw-r--r-- | js/tests/services/starredcountSpec.coffee | 18 |
11 files changed, 125 insertions, 151 deletions
diff --git a/js/tests/services/activefeedSpec.coffee b/js/tests/services/activefeedSpec.coffee index f8b3a17ea..7268426e9 100644 --- a/js/tests/services/activefeedSpec.coffee +++ b/js/tests/services/activefeedSpec.coffee @@ -21,32 +21,25 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -describe '_ActiveFeed', -> - +describe 'ActiveFeed', -> beforeEach module 'News' - beforeEach inject (@_ActiveFeed, @FeedType) => + beforeEach inject (@ActiveFeed, @FeedType) => @data = id: 5 type: 3 it 'should be Subscriptions by default', => - active = new @_ActiveFeed() - - expect(active.getType()).toBe(@FeedType.Subscriptions) + expect(@ActiveFeed.getType()).toBe(@FeedType.Subscriptions) it 'should set the correct feed id', => - active = new @_ActiveFeed() - active.handle(@data) - - expect(active.getId()).toBe(5) + @ActiveFeed.handle(@data) + expect(@ActiveFeed.getId()).toBe(5) it 'should set the correct feed type', => - active = new @_ActiveFeed() - active.handle(@data) - - expect(active.getType()).toBe(3)
\ No newline at end of file + @ActiveFeed.handle(@data) + expect(@ActiveFeed.getType()).toBe(3)
\ No newline at end of file diff --git a/js/tests/services/bl/feedblSpec.coffee b/js/tests/services/bl/feedblSpec.coffee index 7cc2e9ab3..486c32198 100644 --- a/js/tests/services/bl/feedblSpec.coffee +++ b/js/tests/services/bl/feedblSpec.coffee @@ -21,23 +21,21 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -describe '_FeedBl', -> - +describe 'FeedBl', -> beforeEach module 'News' - beforeEach inject (@_FeedBl, @FeedModel, @ItemModel, @_ItemBl) => - @persistence = - getItems: -> - - @itemBl = new _ItemBl(@ItemModel, @persistence) + beforeEach => + angular.module('News').factory 'Persistence', => + @persistence = + getItems: -> - @bl = new @_FeedBl(@FeedModel, @itemBl, @persistence) + beforeEach inject (@FeedBl, @FeedModel, @ItemModel) => it 'should return the number of unread feeds', => @FeedModel.add({id: 3, unreadCount:134, urlHash: 'a1'}) - count = @bl.getUnreadCount(3) + count = @FeedBl.getUnreadCount(3) expect(count).toBe(134) @@ -50,7 +48,7 @@ describe '_FeedBl', -> @FeedModel.add(feed2) @FeedModel.add(feed3) - feeds = @bl.getFeedsOfFolder(3) + feeds = @FeedBl.getFeedsOfFolder(3) expect(feeds).toContain(feed1) expect(feeds).toContain(feed3) @@ -61,7 +59,7 @@ describe '_FeedBl', -> @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a2'}) @FeedModel.add({id: 1, unreadCount:12, folderId: 5, urlHash: 'a3'}) @FeedModel.add({id: 2, unreadCount:35, folderId: 3, urlHash: 'a4'}) - count = @bl.getFolderUnreadCount(3) + count = @FeedBl.getFolderUnreadCount(3) expect(count).toBe(169) @@ -69,7 +67,7 @@ describe '_FeedBl', -> it 'should delete feeds', => @FeedModel.removeById = jasmine.createSpy('remove') @persistence.deleteFeed = jasmine.createSpy('deletequery') - @bl.delete(3) + @FeedBl.delete(3) expect(@FeedModel.removeById).toHaveBeenCalledWith(3) expect(@persistence.deleteFeed).toHaveBeenCalledWith(3) @@ -82,7 +80,7 @@ describe '_FeedBl', -> @ItemModel.add({id: 6, feedId: 5, guidHash: 'a1'}) @ItemModel.add({id: 3, feedId: 5, guidHash: 'a2'}) @ItemModel.add({id: 2, feedId: 5, guidHash: 'a3'}) - @bl.markFeedRead(5) + @FeedBl.markFeedRead(5) expect(@persistence.setFeedRead).toHaveBeenCalledWith(5, 6) expect(@FeedModel.getById(5).unreadCount).toBe(0) @@ -94,7 +92,7 @@ describe '_FeedBl', -> @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a2'}) @FeedModel.add({id: 1, unreadCount:12, folderId: 3, urlHash: 'a3'}) - @bl.markAllRead() + @FeedBl.markAllRead() expect(@FeedModel.getById(3).unreadCount).toBe(0) expect(@FeedModel.getById(1).unreadCount).toBe(0) @@ -104,6 +102,6 @@ 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 = @bl.getUnreadCount() + count = @FeedBl.getUnreadCount() expect(count).toBe(136)
\ No newline at end of file diff --git a/js/tests/services/bl/folderblSpec.coffee b/js/tests/services/bl/folderblSpec.coffee index 898aaecba..9ede654ee 100644 --- a/js/tests/services/bl/folderblSpec.coffee +++ b/js/tests/services/bl/folderblSpec.coffee @@ -21,24 +21,22 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -describe '_FolderBl', -> - +describe 'FolderBl', -> beforeEach module 'News' - beforeEach inject (@_FolderBl, @FolderModel, @_FeedBl, @_ItemBl, - @FeedModel, @ItemModel) => - @persistence = - getItems: -> - itemBl = new @_ItemBl(@ItemModel, @persistence) - feedBl = new @_FeedBl(FeedModel, itemBl, @persistence) - @bl = new @_FolderBl(@FolderModel, feedBl, @persistence) + beforeEach => + angular.module('News').factory 'Persistence', => + @persistence = + getItems: -> + + beforeEach inject (@FolderBl, @FolderModel, @FeedModel) => it 'should delete folders', => @FolderModel.removeById = jasmine.createSpy('remove') @persistence.deleteFolder = jasmine.createSpy('deletequery') - @bl.delete(3) + @FolderBl.delete(3) expect(@FolderModel.removeById).toHaveBeenCalledWith(3) expect(@persistence.deleteFolder).toHaveBeenCalledWith(3) @@ -46,10 +44,10 @@ describe '_FolderBl', -> it 'should return true when folder has feeds', => @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'}) - expect(@bl.hasFeeds(3)).toBeFalsy() + expect(@FolderBl.hasFeeds(3)).toBeFalsy() @FeedModel.add({id: 2, unreadCount:35, folderId: 3, urlHash: 'a2'}) - expect(@bl.hasFeeds(3)).toBeTruthy() + expect(@FolderBl.hasFeeds(3)).toBeTruthy() it 'should toggle folder', => @@ -57,14 +55,14 @@ describe '_FolderBl', -> @persistence.collapseFolder = jasmine.createSpy('collapse') @FolderModel.add({id: 3, open: false}) - @bl.toggleFolder(4) + @FolderBl.toggleFolder(4) expect(@FolderModel.getById(3).open).toBeFalsy() - @bl.toggleFolder(3) + @FolderBl.toggleFolder(3) expect(@FolderModel.getById(3).open).toBeTruthy() expect(@persistence.openFolder).toHaveBeenCalledWith(3) - @bl.toggleFolder(3) + @FolderBl.toggleFolder(3) expect(@FolderModel.getById(3).open).toBeFalsy() expect(@persistence.collapseFolder).toHaveBeenCalledWith(3) @@ -75,7 +73,7 @@ describe '_FolderBl', -> @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a2'}) @FeedModel.add({id: 1, unreadCount:12, folderId: 3, urlHash: 'a3'}) - @bl.markFolderRead(3) + @FolderBl.markFolderRead(3) expect(@FeedModel.getById(3).unreadCount).toBe(0) expect(@FeedModel.getById(1).unreadCount).toBe(0) diff --git a/js/tests/services/bl/itemblSpec.coffee b/js/tests/services/bl/itemblSpec.coffee index f46b178ac..36a283de2 100644 --- a/js/tests/services/bl/itemblSpec.coffee +++ b/js/tests/services/bl/itemblSpec.coffee @@ -21,16 +21,17 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -describe '_ItemBl', -> +describe 'ItemBl', -> beforeEach module 'News' - beforeEach inject (@ItemModel, @_ItemBl, @StatusFlag) => - @persistence = - getItems: -> + beforeEach => + angular.module('News').factory 'Persistence', => + @persistence = + getItems: -> - @bl = new _ItemBl(@ItemModel, @persistence) + beforeEach inject (@ItemModel, @ItemBl, @StatusFlag) => it 'should mark all items read of a feed', => @@ -41,7 +42,7 @@ describe '_ItemBl', -> @ItemModel.add(item1) @ItemModel.add(item2) @ItemModel.add(item3) - @bl.markAllRead(5) + @ItemBl.markAllRead(5) expect(@persistence.setFeedRead).toHaveBeenCalledWith(5, 6) expect(item1.isRead()).toBe(true) diff --git a/js/tests/services/feedtypeSpec.coffee b/js/tests/services/feedtypeSpec.coffee index 4a5855b0c..9299e9906 100644 --- a/js/tests/services/feedtypeSpec.coffee +++ b/js/tests/services/feedtypeSpec.coffee @@ -23,7 +23,6 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. describe 'FeedType', -> - beforeEach module 'News' beforeEach inject (@FeedType) => diff --git a/js/tests/services/models/feedmodelSpec.coffee b/js/tests/services/models/feedmodelSpec.coffee index 08ddabc86..c8980d98a 100644 --- a/js/tests/services/models/feedmodelSpec.coffee +++ b/js/tests/services/models/feedmodelSpec.coffee @@ -21,16 +21,20 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -describe '_FeedModel', -> - +describe 'FeedModel', -> beforeEach module 'News' - beforeEach inject (@_FeedModel, @_Model) => + beforeEach => + angular.module('News').factory 'Utils', => + @utils = + imagePath: jasmine.createSpy('utils') + + beforeEach inject (@FeedModel, @_Model) => - it 'should extend model', => - expect(new @_FeedModel instanceof @_Model).toBeTruthy() + it 'should extend _Model', => + expect(@FeedModel instanceof @_Model).toBeTruthy() it 'should bind an imagepath to the item if the url is empty', => @@ -38,42 +42,31 @@ describe '_FeedModel', -> id: 3 faviconLink: null urlHash: 'hi' - utils = - imagePath: jasmine.createSpy('utils') - - model = new @_FeedModel(utils) - model.add(item) + + @FeedModel.add(item) - expect(utils.imagePath).toHaveBeenCalledWith('news', 'rss.svg') + expect(@utils.imagePath).toHaveBeenCalledWith('news', 'rss.svg') it 'should also update items when url is the same', => - utils = - imagePath: jasmine.createSpy('utils') - model = new @_FeedModel(utils) + @FeedModel.add({id: 2, faviconLink: null, urlHash: 'hi'}) + expect(@FeedModel.size()).toBe(1) - model.add({id: 2, faviconLink: null, urlHash: 'hi'}) - expect(model.size()).toBe(1) + @FeedModel.add({id: 2, faviconLink: null, urlHash: 'hi4'}) + expect(@FeedModel.size()).toBe(1) + expect(@FeedModel.getById(2).urlHash).toBe('hi4') - model.add({id: 2, faviconLink: null, urlHash: 'hi4'}) - expect(model.size()).toBe(1) - expect(model.getById(2).urlHash).toBe('hi4') - - model.add({id: 3, faviconLink: 'hey', urlHash: 'hi4'}) - expect(model.size()).toBe(1) - expect(model.getById(2)).toBe(undefined) - expect(model.getById(3).faviconLink).toBe('hey') + @FeedModel.add({id: 3, faviconLink: 'hey', urlHash: 'hi4'}) + expect(@FeedModel.size()).toBe(1) + expect(@FeedModel.getById(2)).toBe(undefined) + expect(@FeedModel.getById(3).faviconLink).toBe('hey') it 'should also remove the feed from the urlHash cache when its removed', => - utils = - imagePath: jasmine.createSpy('utils') - model = new @_FeedModel(utils) - item = {id: 2, faviconLink: null, urlHash: 'hi'} - model.add(item) + @FeedModel.add(item) - expect(model.getByUrlHash('hi')).toBe(item) + expect(@FeedModel.getByUrlHash('hi')).toBe(item) - model.removeById(2) - expect(model.getByUrlHash('hi')).toBe(undefined)
\ No newline at end of file + @FeedModel.removeById(2) + expect(@FeedModel.getByUrlHash('hi')).toBe(undefined)
\ No newline at end of file diff --git a/js/tests/services/models/foldermodelSpec.coffee b/js/tests/services/models/foldermodelSpec.coffee index bfac1fd49..45714afdd 100644 --- a/js/tests/services/models/foldermodelSpec.coffee +++ b/js/tests/services/models/foldermodelSpec.coffee @@ -20,21 +20,20 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -describe '_FolderModel', -> +describe 'FolderModel', -> beforeEach module 'News' - beforeEach inject (@_FolderModel, @_Model) => + beforeEach inject (@FolderModel, @_Model) => it 'should extend model', => - expect(new @_FolderModel instanceof @_Model).toBeTruthy() + expect(@FolderModel instanceof @_Model).toBeTruthy() it 'should allow to search for foldernames', => - model = new @_FolderModel() - model.add({id: 3, name: 'hi'}) + @FolderModel.add({id: 3, name: 'hi'}) - expect(model.nameExists('hi')).toBeTruthy() - expect(model.nameExists('dhi')).toBeFalsy()
\ No newline at end of file + expect(@FolderModel.nameExists('hi')).toBeTruthy() + expect(@FolderModel.nameExists('dhi')).toBeFalsy()
\ No newline at end of file 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 diff --git a/js/tests/services/opmlparserSpec.coffee b/js/tests/services/opmlparserSpec.coffee index ffdd383ff..ad40fc6dc 100644 --- a/js/tests/services/opmlparserSpec.coffee +++ b/js/tests/services/opmlparserSpec.coffee @@ -21,16 +21,16 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -describe '_OPMLParser', -> +describe 'OPMLParser', -> beforeEach module 'News' - beforeEach inject (@_OPMLParser) => - @parser = new @_OPMLParser() + beforeEach inject (@OPMLParser) => + it 'should return only the root folder when parsing empty OPML', => - @data = @parser.parseXML('') + @data = @OPMLParser.parseXML('') expect(@data.getName()).toBe('root') -
\ No newline at end of file + # TODO: write rest
\ No newline at end of file diff --git a/js/tests/services/showallSpec.coffee b/js/tests/services/showallSpec.coffee index 7eba354f4..c3b54b3b1 100644 --- a/js/tests/services/showallSpec.coffee +++ b/js/tests/services/showallSpec.coffee @@ -21,29 +21,25 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -describe '_ShowAll', -> +describe 'ShowAll', -> beforeEach module 'News' - beforeEach inject (@_ShowAll) => - @showAll = new @_ShowAll() - + beforeEach inject (@ShowAll) => it 'should be false by default', => - - - expect(@showAll.getShowAll()).toBeFalsy() + expect(@ShowAll.getShowAll()).toBeFalsy() - it 'should set the correct showAll value', => - @showAll.handle(true) - expect(@showAll.getShowAll()).toBeTruthy() + it 'should set the correct ShowAll value', => + @ShowAll.handle(true) + expect(@ShowAll.getShowAll()).toBeTruthy() - it 'should provide a set showall setter', => - @showAll.setShowAll(true) - expect(@showAll.getShowAll()).toBeTruthy() + it 'should provide a set Showall setter', => + @ShowAll.setShowAll(true) + expect(@ShowAll.getShowAll()).toBeTruthy() - @showAll.setShowAll(false) - expect(@showAll.getShowAll()).toBeFalsy() + @ShowAll.setShowAll(false) + expect(@ShowAll.getShowAll()).toBeFalsy() diff --git a/js/tests/services/starredcountSpec.coffee b/js/tests/services/starredcountSpec.coffee index 61598324a..bd8c591f1 100644 --- a/js/tests/services/starredcountSpec.coffee +++ b/js/tests/services/starredcountSpec.coffee @@ -21,23 +21,23 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. ### -describe '_StarredCount', -> +describe 'StarredCount', -> beforeEach module 'News' - beforeEach inject (@_StarredCount) => - @starred = new @_StarredCount() + beforeEach inject (@StarredCount) => + it 'should be 0 by default', => - expect(@starred.getStarredCount()).toBe(0) + expect(@StarredCount.getStarredCount()).toBe(0) - it 'should set the correct starred count', => - @starred.handle(3) - expect(@starred.getStarredCount()).toBe(3) + it 'should set the correct StarredCount count', => + @StarredCount.handle(3) + expect(@StarredCount.getStarredCount()).toBe(3) it 'should provide a setter', => - @starred.setStarredCount(15) - expect(@starred.getStarredCount()).toBe(15)
\ No newline at end of file + @StarredCount.setStarredCount(15) + expect(@StarredCount.getStarredCount()).toBe(15)
\ No newline at end of file |