diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-26 14:22:01 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-26 14:22:01 +0100 |
commit | cd3b748f65cc98185c56fd110a140ad2206c319b (patch) | |
tree | 2e51aa3169b2c57ac36472e3db07a47109675c47 /js/tests/controllers/feedcontrollerSpec.coffee | |
parent | b553ff390353a860195b61f5418847880f24410d (diff) |
added adding of feeds logic
Diffstat (limited to 'js/tests/controllers/feedcontrollerSpec.coffee')
-rw-r--r-- | js/tests/controllers/feedcontrollerSpec.coffee | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/js/tests/controllers/feedcontrollerSpec.coffee b/js/tests/controllers/feedcontrollerSpec.coffee index df3917ea8..1a019a74e 100644 --- a/js/tests/controllers/feedcontrollerSpec.coffee +++ b/js/tests/controllers/feedcontrollerSpec.coffee @@ -263,4 +263,73 @@ describe '_FeedController', -> expect(@FeedModel.getById(3).unreadCount).toBe(0) expect(@FeedModel.getById(1).unreadCount).toBe(0) - expect(@FeedModel.getById(5).unreadCount).toBe(0)
\ No newline at end of file + expect(@FeedModel.getById(5).unreadCount).toBe(0) + + + it 'should toggle folder', => + @persistence.openFolder = jasmine.createSpy('open') + @persistence.collapseFolder = jasmine.createSpy('collapse') + + @FolderModel.add({id: 3, open: false}) + @scope.toggleFolder(4) + expect(@FolderModel.getById(3).open).toBeFalsy() + + @scope.toggleFolder(3) + expect(@FolderModel.getById(3).open).toBeTruthy() + expect(@persistence.openFolder).toHaveBeenCalledWith(3) + + @scope.toggleFolder(3) + expect(@FolderModel.getById(3).open).toBeFalsy() + expect(@persistence.collapseFolder).toHaveBeenCalledWith(3) + + + it 'isAddingFolder should return false in the beginning', => + expect(@scope.isAddingFolder()).toBeFalsy() + + + it 'isAddingFeed should return false in the beginning', => + expect(@scope.isAddingFeed()).toBeFalsy() + + + it 'should not add folders that have no name', => + @persistence.createFolder = jasmine.createSpy('create') + @scope.addFolder(' ') + + expect(@scope.folderEmptyError).toBeTruthy() + expect(@persistence.createFolder).not.toHaveBeenCalled() + + + it 'should not add folders that already exist client side', => + @FolderModel.add({id: 3, name: 'ola'}) + @persistence.createFolder = jasmine.createSpy('create') + @scope.addFolder(' Ola') + + expect(@scope.folderExistsError).toBeTruthy() + expect(@persistence.createFolder).not.toHaveBeenCalled() + + + it 'should set isAddingFolder to true if there were no problems', => + @persistence.createFolder = jasmine.createSpy('create') + @scope.addFolder(' Ola') + expect(@scope.isAddingFolder()).toBeTruthy() + + + it 'should create a create new folder request if everything was ok', => + @persistence.createFolder = jasmine.createSpy('create') + @scope.addFolder(' Ola') + expect(@persistence.createFolder).toHaveBeenCalled() + expect(@persistence.createFolder.argsForCall[0][0]).toBe('Ola') + expect(@persistence.createFolder.argsForCall[0][1]).toBe(0) + + + it 'should should reset the foldername on and set isAddingFolder to false',=> + + @persistence.createFolder = + jasmine.createSpy('create').andCallFake (arg1, arg2, func) => + func() + @scope.addFolder(' Ola') + + expect(@scope.folderName).toBe('') + expect(@scope.isAddingFolder()).toBeFalsy() + + |