diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-04 21:57:17 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-04 21:57:17 +0200 |
commit | d001da33947a0fa1b65f0e1b5749e9b97bd4b779 (patch) | |
tree | 73f6ff957e67dc31092a30d883fe36e421bd6b48 /js/tests/controllers | |
parent | 76267670f3dcb6793a62a30477db830f482b4495 (diff) |
cleaned up feedcontroller
Diffstat (limited to 'js/tests/controllers')
-rw-r--r-- | js/tests/controllers/feedcontrollerSpec.coffee | 125 |
1 files changed, 19 insertions, 106 deletions
diff --git a/js/tests/controllers/feedcontrollerSpec.coffee b/js/tests/controllers/feedcontrollerSpec.coffee index 293a55f47..755e84440 100644 --- a/js/tests/controllers/feedcontrollerSpec.coffee +++ b/js/tests/controllers/feedcontrollerSpec.coffee @@ -23,130 +23,43 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. describe '_FeedController', -> - beforeEach module 'News' + beforeEach => + angular.module('News').factory 'Persistence', => + @persistence = {} - beforeEach inject (@_FeedController, @ActiveFeed, @ShowAll, @FeedType, - @StarredCount, @FeedModel, @FolderModel, @FeedBl) => - @scope = - $on: -> - - @persistence = - getItems: -> - - @controller = new @_FeedController(@scope, @FolderModel, @FeedModel, - @ActiveFeed, @ShowAll, @FeedType, - @StarredCount, @persistence, - @FeedBl) - - - xit 'should make folders available', => - @FolderModel.getAll = jasmine.createSpy('FolderModel') - new @_FeedController(@scope, @FolderModel, @FeedModel, @_ActiveFeed) - - expect(@FolderModel.getAll).toHaveBeenCalled() - - - xit 'should make feeds availabe', => - @FeedModel.getAll = jasmine.createSpy('FeedModel') - new @_FeedController(@scope, @FolderModel, @FeedModel, @_ActiveFeed) - - expect(@FeedModel.getAll).toHaveBeenCalled() - - - xit 'should make feedtype available', => - expect(@scope.feedType).toBe(@FeedType) - - - xit 'should check the active feed', => - @ActiveFeed.getType = => - return @FeedType.Feed - @ActiveFeed.getId = => - return 5 - - expect(@scope.isFeedActive(@FeedType.Feed, 5)).toBeTruthy() - - - xit 'should provide ShowAll', => - expect(@scope.isShowAll()).toBeFalsy() - - @ShowAll.setShowAll(true) - expect(@scope.isShowAll()).toBeTruthy() - - - xit 'should handle show all correctly', => - @persistence.userSettingsReadHide = jasmine.createSpy('hide') - @persistence.userSettingsReadShow = jasmine.createSpy('show') - @scope.setShowAll(true) - expect(@ShowAll.getShowAll()).toBeTruthy() - expect(@persistence.userSettingsReadShow).toHaveBeenCalled() - expect(@persistence.userSettingsReadHide).not.toHaveBeenCalled() + beforeEach inject (@_FeedController, @FolderBl, @FeedBl, $rootScope, + @unreadCountFormatter) => + @scope = $rootScope.$new() + @controller = new @_FeedController(@scope, @persistence, @FolderBl, + @FeedBl, @unreadCountFormatter) - xit 'should handle hide all correctly', => - @persistence.userSettingsReadHide = jasmine.createSpy('hide') - @persistence.userSettingsReadShow = jasmine.createSpy('show') - @scope.setShowAll(false) - expect(@ShowAll.getShowAll()).toBeFalsy() - expect(@persistence.userSettingsReadShow).not.toHaveBeenCalled() - expect(@persistence.userSettingsReadHide).toHaveBeenCalled() + it 'isAddingFolder should return false in the beginning', => + expect(@scope.isAddingFolder()).toBeFalsy() - xit 'should get the correct count for starred items', => - @StarredCount.setStarredCount(133) - count = @scope.getUnreadCount(@FeedType.Starred, 0) - - expect(count).toBe(133) - - - xit 'should set the count to 999+ if the count is over 999', => - @StarredCount.setStarredCount(1000) - count = @scope.getUnreadCount(@FeedType.Starred, 0) - - expect(count).toBe('999+') - - - - - - xit 'should set active feed to new feed if changed', => - @ActiveFeed.handle({id: 3, type: 3}) - @scope.loadFeed(4, 3) - - expect(@ActiveFeed.getId()).toBe(3) - expect(@ActiveFeed.getType()).toBe(4) - - - xit 'should return true when calling isShown and there are feeds', => - @FeedModel.add({id: 3}) - @ShowAll.setShowAll(true) - expect(@scope.isShown(3, 4)).toBeTruthy() - - @ShowAll.setShowAll(false) - expect(@scope.isShown(3, 4)).toBeFalsy() + it 'isAddingFeed should return false in the beginning', => + expect(@scope.isAddingFeed()).toBeFalsy() - xit 'should return true if ShowAll is false but unreadcount is not 0', => - @ShowAll.setShowAll(false) - @FeedModel.add({id: 4, unreadCount: 0, urlHash: 'a1'}) - expect(@scope.isShown(@FeedType.Feed, 4)).toBeFalsy() - @FeedModel.add({id: 4, unreadCount: 12, urlHash: 'a2'}) - expect(@scope.isShown(@FeedType.Feed, 4)).toBeTruthy() + it 'should make unreadCountFormatter available', => + expect(@scope.unreadCountFormatter).toBe(@unreadCountFormatter) - xit 'isAddingFolder should return false in the beginning', => - expect(@scope.isAddingFolder()).toBeFalsy() + it 'should make FeedBl available', => + expect(@scope.feedBl).toBe(@FeedBl) - xit 'isAddingFeed should return false in the beginning', => - expect(@scope.isAddingFeed()).toBeFalsy() + it 'should make FolderBl available', => + expect(@scope.folderBl).toBe(@FolderBl) - xit 'should not add folders that have no name', => + it 'should not add folders that have no name', => @persistence.createFolder = jasmine.createSpy('create') @scope.addFolder(' ') |