diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-26 14:45:39 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-26 14:45:39 +0100 |
commit | 8e1e0f5281c1ee49fe7f6d84ba8f2b709ebf7f40 (patch) | |
tree | 30bc99a02a414de50e1461c9f6b6289b44e3c543 /js/tests/controllers | |
parent | cd3b748f65cc98185c56fd110a140ad2206c319b (diff) |
added logic for adding feeds
Diffstat (limited to 'js/tests/controllers')
-rw-r--r-- | js/tests/controllers/feedcontrollerSpec.coffee | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/js/tests/controllers/feedcontrollerSpec.coffee b/js/tests/controllers/feedcontrollerSpec.coffee index 1a019a74e..af4c8f9a7 100644 --- a/js/tests/controllers/feedcontrollerSpec.coffee +++ b/js/tests/controllers/feedcontrollerSpec.coffee @@ -323,7 +323,6 @@ describe '_FeedController', -> it 'should should reset the foldername on and set isAddingFolder to false',=> - @persistence.createFolder = jasmine.createSpy('create').andCallFake (arg1, arg2, func) => func() @@ -333,3 +332,53 @@ describe '_FeedController', -> expect(@scope.isAddingFolder()).toBeFalsy() + it 'should not add feeds that have no url', => + @persistence.createFeed = jasmine.createSpy('create') + @scope.addFeed(' ') + + expect(@scope.feedEmptyError).toBeTruthy() + expect(@persistence.createFeed).not.toHaveBeenCalled() + + + it 'should not add feeds that already exist client side', => + @FeedModel.add({id: 3, url: 'ola'}) + @persistence.createFeed = jasmine.createSpy('create') + @scope.addFeed('ola') + + expect(@scope.feedExistsError).toBeTruthy() + expect(@persistence.createFeed).not.toHaveBeenCalled() + + + it 'should set isAddingFeed to true if there were no problems', => + @persistence.createFeed = jasmine.createSpy('create') + @scope.addFeed('ola') + expect(@scope.isAddingFeed()).toBeTruthy() + + + it 'should should reset the feedurl and set isAddingFeed to false on succ',=> + @persistence.createFeed = + jasmine.createSpy('create').andCallFake (arg1, arg2, func) => + func() + @scope.addFeed(' Ola') + + expect(@scope.feedUrl).toBe('') + expect(@scope.isAddingFeed()).toBeFalsy() + + + it 'should should set isAddingFeed to false on err',=> + @persistence.createFeed = + jasmine.createSpy('create').andCallFake (arg1, arg2, func, err) => + err() + @scope.addFeed('Ola') + + expect(@scope.isAddingFeed()).toBeFalsy() + expect(@scope.feedError).toBeTruthy() + + + it 'should create a create new feed request if everything was ok', => + @persistence.createFeed = jasmine.createSpy('create') + @scope.addFeed('Ola') + expect(@persistence.createFeed).toHaveBeenCalled() + expect(@persistence.createFeed.argsForCall[0][0]).toBe('Ola') + expect(@persistence.createFeed.argsForCall[0][1]).toBe(0) + |