diff options
Diffstat (limited to 'js/build/tests/services/businesslayer/starredbusinesslayerSpec.js')
-rw-r--r-- | js/build/tests/services/businesslayer/starredbusinesslayerSpec.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/js/build/tests/services/businesslayer/starredbusinesslayerSpec.js b/js/build/tests/services/businesslayer/starredbusinesslayerSpec.js new file mode 100644 index 000000000..80fa1c5fc --- /dev/null +++ b/js/build/tests/services/businesslayer/starredbusinesslayerSpec.js @@ -0,0 +1,69 @@ +// Generated by CoffeeScript 1.6.3 +/* + +ownCloud - News + +@author Bernhard Posselt +@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +License as published by the Free Software Foundation; either +version 3 of the License, or any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU AFFERO GENERAL PUBLIC LICENSE for more details. + +You should have received a copy of the GNU Affero General Public +License along with this library. If not, see <http://www.gnu.org/licenses/>. +*/ + + +(function() { + describe('StarredBusinessLayer', function() { + var _this = this; + beforeEach(module('News')); + beforeEach(module(function($provide) { + _this.persistence = { + test: 'starredbusinesslayer' + }; + $provide.value('Persistence', _this.persistence); + })); + beforeEach(inject(function(StarredBusinessLayer, StarredCount, ActiveFeed, FeedType) { + _this.StarredBusinessLayer = StarredBusinessLayer; + _this.StarredCount = StarredCount; + _this.ActiveFeed = ActiveFeed; + _this.FeedType = FeedType; + _this.ActiveFeed.handle({ + type: _this.FeedType.Feed, + id: 0 + }); + return _this.StarredCount.setStarredCount(0); + })); + it('should not be visible if starredCount is 0', function() { + expect(_this.StarredBusinessLayer.isVisible()).toBe(false); + _this.StarredCount.setStarredCount(144); + return expect(_this.StarredBusinessLayer.isVisible()).toBe(true); + }); + it('should always be visible if its the active feed', function() { + _this.ActiveFeed.handle({ + type: _this.FeedType.Starred, + id: 0 + }); + return expect(_this.StarredBusinessLayer.isVisible()).toBe(true); + }); + it('should get the correct unread count', function() { + _this.StarredCount.setStarredCount(144); + return expect(_this.StarredBusinessLayer.getUnreadCount()).toBe(144); + }); + it('should increase the starred count', function() { + return expect(_this.StarredBusinessLayer.increaseCount()).toBe(1); + }); + return it('should decrease the starred count', function() { + return expect(_this.StarredBusinessLayer.decreaseCount()).toBe(-1); + }); + }); + +}).call(this); |