diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-09 16:37:04 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-09 16:37:04 +0200 |
commit | 4a8984a9970b4a6122ea9b31f20380cdbbca39da (patch) | |
tree | cf3ef8cab5f1560a97cb14118b56b522afb30192 /js/build/tests/services/businesslayer/businesslayerSpec.js | |
parent | a84b978221e017399b515280a3f758e8f99eaf93 (diff) |
dont ignore vendor build directories
Diffstat (limited to 'js/build/tests/services/businesslayer/businesslayerSpec.js')
-rw-r--r-- | js/build/tests/services/businesslayer/businesslayerSpec.js | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/js/build/tests/services/businesslayer/businesslayerSpec.js b/js/build/tests/services/businesslayer/businesslayerSpec.js new file mode 100644 index 000000000..8a5a9c1b2 --- /dev/null +++ b/js/build/tests/services/businesslayer/businesslayerSpec.js @@ -0,0 +1,88 @@ +// 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() { + var __hasProp = {}.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + + describe('BusinessLayer', function() { + var _this = this; + beforeEach(module('News')); + beforeEach(inject(function(_BusinessLayer, ActiveFeed, FeedType, ItemModel) { + var TestBusinessLayer, type; + _this._BusinessLayer = _BusinessLayer; + _this.ActiveFeed = ActiveFeed; + _this.FeedType = FeedType; + _this.ItemModel = ItemModel; + type = _this.FeedType.Starred; + _this.getItemsSpy = jasmine.createSpy('getItems'); + _this.persistence = { + getItems: _this.getItemsSpy + }; + TestBusinessLayer = (function(_super) { + __extends(TestBusinessLayer, _super); + + function TestBusinessLayer(activeFeed, persistence, itemModel) { + TestBusinessLayer.__super__.constructor.call(this, activeFeed, persistence, itemModel, type); + } + + return TestBusinessLayer; + + })(_this._BusinessLayer); + return _this.BusinessLayer = new TestBusinessLayer(_this.ActiveFeed, _this.persistence, _this.ItemModel); + })); + it('should reset the item cache when a different feed is being loaded', function() { + _this.ItemModel.clear = jasmine.createSpy('clear'); + _this.ActiveFeed.handle({ + id: 0, + type: _this.FeedType.Starred + }); + _this.BusinessLayer.load(2); + expect(_this.ItemModel.clear).toHaveBeenCalled(); + _this.ActiveFeed.handle({ + id: 2, + type: _this.FeedType.Feed + }); + _this.BusinessLayer.load(2); + return expect(_this.ItemModel.clear).toHaveBeenCalled(); + }); + it('should send a get all items query when feed changed', function() { + _this.persistence.getItems = jasmine.createSpy('latest'); + _this.ActiveFeed.handle({ + id: 3, + type: _this.FeedType.Feed + }); + _this.BusinessLayer.load(3); + return expect(_this.persistence.getItems).toHaveBeenCalledWith(_this.FeedType.Starred, 3, 0); + }); + return it('should be active when its selected', function() { + expect(_this.BusinessLayer.isActive(0)).toBe(false); + _this.ActiveFeed.handle({ + type: _this.FeedType.Starred, + id: 0 + }); + return expect(_this.BusinessLayer.isActive(0)).toBe(true); + }); + }); + +}).call(this); |