From d54475fb0f168845bf14b0d16088da97d473187a Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 9 Sep 2013 16:38:08 +0200 Subject: log --- js/build/tests/controllers/feedcontrollerSpec.js | 233 --------- js/build/tests/controllers/itemcontrollerSpec.js | 194 ------- .../tests/controllers/settingscontrollerSpec.js | 86 --- js/build/tests/services/activefeedSpec.js | 49 -- .../services/businesslayer/businesslayerSpec.js | 88 ---- .../businesslayer/feedbusinesslayerSpec.js | 478 ----------------- .../businesslayer/folderbusinesslayerSpec.js | 577 --------------------- .../businesslayer/itembusinesslayerSpec.js | 330 ------------ .../businesslayer/starredbusinesslayerSpec.js | 69 --- .../businesslayer/subsriptionsbusinesslayerSpec.js | 130 ----- js/build/tests/services/feedtypeSpec.js | 48 -- js/build/tests/services/languageSpec.js | 61 --- js/build/tests/services/models/feedmodelSpec.js | 175 ------- js/build/tests/services/models/foldermodelSpec.js | 140 ----- js/build/tests/services/models/itemmodelSpec.js | 160 ------ js/build/tests/services/newestitemSpec.js | 41 -- js/build/tests/services/opmlparserSpec.js | 167 ------ js/build/tests/services/persistenceSpec.js | 398 -------------- js/build/tests/services/showallSpec.js | 46 -- js/build/tests/services/starredcountSpec.js | 44 -- js/build/tests/services/statusflagSpec.js | 39 -- js/build/tests/services/unreadcountformaterSpec.js | 39 -- 22 files changed, 3592 deletions(-) delete mode 100644 js/build/tests/controllers/feedcontrollerSpec.js delete mode 100644 js/build/tests/controllers/itemcontrollerSpec.js delete mode 100644 js/build/tests/controllers/settingscontrollerSpec.js delete mode 100644 js/build/tests/services/activefeedSpec.js delete mode 100644 js/build/tests/services/businesslayer/businesslayerSpec.js delete mode 100644 js/build/tests/services/businesslayer/feedbusinesslayerSpec.js delete mode 100644 js/build/tests/services/businesslayer/folderbusinesslayerSpec.js delete mode 100644 js/build/tests/services/businesslayer/itembusinesslayerSpec.js delete mode 100644 js/build/tests/services/businesslayer/starredbusinesslayerSpec.js delete mode 100644 js/build/tests/services/businesslayer/subsriptionsbusinesslayerSpec.js delete mode 100644 js/build/tests/services/feedtypeSpec.js delete mode 100644 js/build/tests/services/languageSpec.js delete mode 100644 js/build/tests/services/models/feedmodelSpec.js delete mode 100644 js/build/tests/services/models/foldermodelSpec.js delete mode 100644 js/build/tests/services/models/itemmodelSpec.js delete mode 100644 js/build/tests/services/newestitemSpec.js delete mode 100644 js/build/tests/services/opmlparserSpec.js delete mode 100644 js/build/tests/services/persistenceSpec.js delete mode 100644 js/build/tests/services/showallSpec.js delete mode 100644 js/build/tests/services/starredcountSpec.js delete mode 100644 js/build/tests/services/statusflagSpec.js delete mode 100644 js/build/tests/services/unreadcountformaterSpec.js (limited to 'js/build/tests') diff --git a/js/build/tests/controllers/feedcontrollerSpec.js b/js/build/tests/controllers/feedcontrollerSpec.js deleted file mode 100644 index 810a5fa09..000000000 --- a/js/build/tests/controllers/feedcontrollerSpec.js +++ /dev/null @@ -1,233 +0,0 @@ -// 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 . -*/ - - -(function() { - describe('FeedController', function() { - var _this = this; - beforeEach(module('News')); - beforeEach(module(function($provide) { - _this.imagePath = jasmine.createSpy('imagePath'); - _this.utils = { - imagePath: _this.imagePath - }; - $provide.value('Utils', _this.utils); - _this.persistence = {}; - $provide.value('Persistence', _this.persistence); - })); - beforeEach(inject(function($controller, FolderBusinessLayer, FeedBusinessLayer, $rootScope, unreadCountFormatter, FeedModel, SubscriptionsBusinessLayer, StarredBusinessLayer, $window, _ExistsError, FolderModel, FeedType) { - var replace; - _this.FolderBusinessLayer = FolderBusinessLayer; - _this.FeedBusinessLayer = FeedBusinessLayer; - _this.unreadCountFormatter = unreadCountFormatter; - _this.FeedModel = FeedModel; - _this.SubscriptionsBusinessLayer = SubscriptionsBusinessLayer; - _this.StarredBusinessLayer = StarredBusinessLayer; - _this.$window = $window; - _this._ExistsError = _ExistsError; - _this.FolderModel = FolderModel; - _this.FeedType = FeedType; - _this.scope = $rootScope.$new(); - replace = { - $scope: _this.scope - }; - _this.$window.document.title = ''; - return _this.controller = $controller('FeedController', replace); - })); - it('isAddingFolder should return false in the beginning', function() { - return expect(_this.scope.isAddingFolder()).toBeFalsy(); - }); - it('isAddingFeed should return false in the beginning', function() { - return expect(_this.scope.isAddingFeed()).toBeFalsy(); - }); - it('should make unreadCountFormatter available', function() { - return expect(_this.scope.unreadCountFormatter).toBe(_this.unreadCountFormatter); - }); - it('should make FeedBusinessLayer available', function() { - return expect(_this.scope.feedBusinessLayer).toBe(_this.FeedBusinessLayer); - }); - it('should make FolderBusinessLayer available', function() { - return expect(_this.scope.folderBusinessLayer).toBe(_this.FolderBusinessLayer); - }); - it('should make SubscriptionsBusinessLayer available', function() { - return expect(_this.scope.subscriptionsBusinessLayer).toBe(_this.SubscriptionsBusinessLayer); - }); - it('should make StarredBusinessLayer available', function() { - return expect(_this.scope.starredBusinessLayer).toBe(_this.StarredBusinessLayer); - }); - it('should set the window title to the total unread count', function() { - var item; - expect(_this.$window.document.title).toBe(''); - _this.scope.getTotalUnreadCount(); - expect(_this.$window.document.title).toBe('News | ownCloud'); - item = { - id: 3, - unreadCount: 5, - faviconLink: 'test', - url: 'hi' - }; - _this.FeedModel.add(item); - _this.scope.getTotalUnreadCount(); - return expect(_this.$window.document.title).toBe('News (5) | ownCloud'); - }); - it('should show 99+ if in window title when more than 99 unread count', function() { - var item, item1; - item = { - id: 3, - unreadCount: 1, - faviconLink: 'test', - url: 'hi' - }; - item1 = { - id: 5, - unreadCount: 999, - faviconLink: 'test', - url: 'his' - }; - _this.FeedModel.add(item); - _this.FeedModel.add(item1); - _this.scope.getTotalUnreadCount(); - return expect(_this.$window.document.title).toBe('News (999+) | ownCloud'); - }); - it('should move a feed if moveFeedToFolder is broadcasted', function() { - var item; - item = { - id: 3, - unreadCount: 1, - faviconLink: 'test', - url: 'hi' - }; - _this.FeedModel.add(item); - _this.persistence.moveFeed = jasmine.createSpy('move feed'); - _this.scope.$broadcast('moveFeedToFolder', { - feedId: 3, - folderId: 1 - }); - return expect(_this.persistence.moveFeed).toHaveBeenCalledWith(3, 1); - }); - it('should set isAddingFolder to true if there were no problems', function() { - _this.persistence.createFolder = jasmine.createSpy('create'); - _this.scope.addFolder(' Ola'); - return expect(_this.scope.isAddingFolder()).toBe(true); - }); - it('should set isAddingFolder to false after a failed request', function() { - _this.persistence.createFolder = jasmine.createSpy('create'); - _this.persistence.createFolder.andCallFake(function(name, id, onSuccess, onFailure) { - return onFailure(); - }); - _this.scope.addFolder(' Ola'); - return expect(_this.scope.isAddingFolder()).toBe(false); - }); - it('should show an error if the folder exists and reset the input', function() { - _this.FolderBusinessLayer.create = jasmine.createSpy('create'); - _this.FolderBusinessLayer.create.andCallFake(function() { - throw new _this._ExistsError('ye'); - }); - _this.scope.addFolder(' Ola'); - expect(_this.scope.folderExistsError).toBe(true); - return expect(_this.scope.isAddingFolder()).toBe(false); - }); - it('should reset the add folder form and set the created as selected', function() { - var data; - _this.persistence.createFolder = jasmine.createSpy('create'); - data = { - data: { - folders: [ - { - id: 3, - name: 'soba' - } - ] - }, - status: 'success' - }; - _this.persistence.createFolder.andCallFake(function(id, parent, onSuccess) { - _this.FolderModel.handle(data.data.folders); - return onSuccess(data); - }); - _this.scope.addFolder(' Soba'); - expect(_this.scope.folderName).toBe(''); - expect(_this.scope.addNewFolder).toBe(false); - expect(_this.scope.isAddingFolder()).toBe(false); - return expect(_this.scope.folderId.name).toBe('soba'); - }); - it('should set isAddingFeed to true if there were no problems', function() { - _this.persistence.createFeed = jasmine.createSpy('create'); - _this.scope.addFeed('Ola'); - return expect(_this.scope.isAddingFeed()).toBe(true); - }); - it('should set isAddingFeed to false after a failed request', function() { - _this.persistence.createFeed = jasmine.createSpy('create'); - _this.persistence.createFeed.andCallFake(function(name, id, onSuccess, onFailure) { - return onFailure(); - }); - _this.scope.addFolder(' Ola'); - return expect(_this.scope.isAddingFeed()).toBe(false); - }); - it('should show an error if the feed exists and reset the input', function() { - _this.FeedBusinessLayer.create = jasmine.createSpy('create'); - _this.FeedBusinessLayer.create.andCallFake(function() { - throw new _this._ExistsError('ye'); - }); - _this.scope.addFeed(' Ola'); - expect(_this.scope.feedExistsError).toBe(true); - return expect(_this.scope.isAddingFeed()).toBe(false); - }); - it('should open the parent folder of the added feed', function() { - var item; - item = { - opened: false, - id: 3, - name: 'john' - }; - _this.FolderModel.add(item); - _this.scope.addFeed(' Ola', 3); - return expect(item.opened).toBe(true); - }); - return it('should reset the add feed form and load the added feed', function() { - var data; - _this.persistence.createFeed = jasmine.createSpy('create'); - _this.persistence.getItems = jasmine.createSpy('load'); - data = { - data: { - feeds: [ - { - id: 3, - url: 'http://soba', - title: 'hi' - } - ] - }, - status: 'success' - }; - _this.persistence.createFeed.andCallFake(function(id, parent, onSuccess) { - _this.FeedModel.handle(data.data.feeds); - return onSuccess(data); - }); - _this.scope.addFeed(' Soba'); - expect(_this.scope.feedUrl).toBe(''); - expect(_this.scope.isAddingFeed()).toBe(false); - return expect(_this.persistence.getItems).toHaveBeenCalledWith(_this.FeedType.Feed, 3, 0); - }); - }); - -}).call(this); diff --git a/js/build/tests/controllers/itemcontrollerSpec.js b/js/build/tests/controllers/itemcontrollerSpec.js deleted file mode 100644 index bf4ea4afc..000000000 --- a/js/build/tests/controllers/itemcontrollerSpec.js +++ /dev/null @@ -1,194 +0,0 @@ -// 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 . -*/ - - -(function() { - describe('ItemController', function() { - var _this = this; - beforeEach(module('News')); - beforeEach(module(function($provide) { - _this.imagePath = jasmine.createSpy('imagePath'); - _this.utils = { - imagePath: _this.imagePath - }; - $provide.value('Utils', _this.utils); - _this.persistence = { - getItems: function() {}, - readItem: function() {} - }; - $provide.value('Persistence', _this.persistence); - })); - beforeEach(inject(function($controller, ItemBusinessLayer, FeedBusinessLayer, $rootScope, FeedLoading, AutoPageLoading, FeedModel, ItemModel, ActiveFeed, FeedType, NewestItem) { - var replace; - _this.ItemBusinessLayer = ItemBusinessLayer; - _this.FeedBusinessLayer = FeedBusinessLayer; - _this.FeedLoading = FeedLoading; - _this.AutoPageLoading = AutoPageLoading; - _this.FeedModel = FeedModel; - _this.ItemModel = ItemModel; - _this.ActiveFeed = ActiveFeed; - _this.FeedType = FeedType; - _this.NewestItem = NewestItem; - _this.ActiveFeed.handle({ - type: _this.FeedType.Folder, - id: 3 - }); - _this.scope = $rootScope.$new(); - replace = { - $scope: _this.scope - }; - return _this.controller = $controller('ItemController', replace); - })); - it('should make ItemBusinessLayer availabe', function() { - return expect(_this.scope.itemBusinessLayer).toBe(_this.ItemBusinessLayer); - }); - it('should make FeedBusinessLayer availabe', function() { - return expect(_this.scope.feedBusinessLayer).toBe(_this.FeedBusinessLayer); - }); - it('should make feedloading available', function() { - expect(_this.scope.isLoading()).toBe(false); - _this.FeedLoading.increase(); - return expect(_this.scope.isLoading()).toBe(true); - }); - it('should make autopagin available', function() { - expect(_this.scope.isAutoPaging()).toBe(false); - _this.AutoPageLoading.increase(); - return expect(_this.scope.isAutoPaging()).toBe(true); - }); - it('should return the feedtitle', function() { - var item; - item = { - id: 3, - faviconLink: null, - url: 'hi', - title: 'heheh' - }; - _this.FeedModel.add(item); - return expect(_this.scope.getFeedTitle(3)).toBe(item.title); - }); - it('should return no value if feedtitle is not found', function() { - return expect(_this.scope.getFeedTitle(3)).toBe(''); - }); - it('should return no value if relative date gets no value', function() { - return expect(_this.scope.getRelativeDate()).toBe(''); - }); - it('should set an item read on readItem broadcast', function() { - var item1; - item1 = { - id: 4, - guidHash: 'abc', - feedId: 3 - }; - _this.ItemModel.add(item1); - item1.setUnread(); - expect(item1.isRead()).toBe(false); - _this.scope.$broadcast('readItem', 4); - return expect(item1.isRead()).toBe(true); - }); - it('should not autopage if there are no items', function() { - _this.persistence.getItems = jasmine.createSpy('getItems'); - _this.scope.$broadcast('autoPage'); - return expect(_this.persistence.getItems).not.toHaveBeenCalled(); - }); - it('should autoPage with the lowest Item Id', function() { - var item1; - _this.NewestItem.handle(25); - _this.persistence.getItems = jasmine.createSpy('getItems'); - item1 = { - id: 4, - guidHash: 'abc', - feedId: 3 - }; - _this.ItemModel.add(item1); - item1 = { - id: 3, - guidHash: 'abcd', - feedId: 3 - }; - _this.ItemModel.add(item1); - item1 = { - id: 6, - guidHash: 'abce', - feedId: 1 - }; - _this.ItemModel.add(item1); - _this.scope.$broadcast('autoPage'); - return expect(_this.persistence.getItems).toHaveBeenCalledWith(_this.FeedType.Folder, 3, 3, jasmine.any(Function)); - }); - it('should not prevent autopaging if there are no items', function() { - var item1; - _this.scope.$broadcast('autoPage'); - _this.persistence.getItems = jasmine.createSpy('getItems'); - item1 = { - id: 3, - guidHash: 'abcd', - feedId: 3 - }; - _this.ItemModel.add(item1); - _this.scope.$broadcast('autoPage'); - return expect(_this.persistence.getItems).toHaveBeenCalledWith(_this.FeedType.Folder, 3, 3, jasmine.any(Function)); - }); - it('should not send multiple autopage requests at once', function() { - var item1; - _this.persistence.getItems = jasmine.createSpy('getItems'); - item1 = { - id: 3, - guidHash: 'abcd', - feedId: 3 - }; - _this.ItemModel.add(item1); - _this.scope.$broadcast('autoPage'); - item1 = { - id: 2, - guidHash: 'abcd', - feedId: 3 - }; - _this.ItemModel.add(item1); - _this.scope.$broadcast('autoPage'); - return expect(_this.persistence.getItems).not.toHaveBeenCalledWith(_this.FeedType.Folder, 2, 3, jasmine.any(Function)); - }); - return it('should allow another autopaging request if the last one finished', function() { - var item1; - _this.NewestItem.handle(25); - _this.persistence.getItems = jasmine.createSpy('getItems'); - _this.persistence.getItems.andCallFake(function(type, id, offset, onSuccess) { - return onSuccess(); - }); - item1 = { - id: 3, - guidHash: 'abcd', - feedId: 3 - }; - _this.ItemModel.add(item1); - _this.scope.$broadcast('autoPage'); - item1 = { - id: 2, - guidHash: 'abcd', - feedId: 3 - }; - _this.ItemModel.add(item1); - _this.scope.$broadcast('autoPage'); - return expect(_this.persistence.getItems.callCount).toBe(2); - }); - }); - -}).call(this); diff --git a/js/build/tests/controllers/settingscontrollerSpec.js b/js/build/tests/controllers/settingscontrollerSpec.js deleted file mode 100644 index 1b6d7dff0..000000000 --- a/js/build/tests/controllers/settingscontrollerSpec.js +++ /dev/null @@ -1,86 +0,0 @@ -// 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 . -*/ - - -(function() { - describe('SettingsController', function() { - var _this = this; - beforeEach(module('News')); - beforeEach(module(function($provide) { - _this.persistence = {}; - $provide.value('Persistence', _this.persistence); - })); - beforeEach(inject(function($controller, FeedBusinessLayer, FolderBusinessLayer, ShowAll) { - _this.FeedBusinessLayer = FeedBusinessLayer; - _this.FolderBusinessLayer = FolderBusinessLayer; - _this.ShowAll = ShowAll; - _this.scope = {}; - _this.replace = { - '$scope': _this.scope, - 'FolderBusinessLayer': { - "import": jasmine.createSpy('import') - } - }; - return _this.controller = $controller('SettingsController', _this.replace); - })); - it('should make FeedBl available', function() { - return expect(_this.scope.feedBl).toBe(_this.FeedBl); - }); - it('should show an error if the xml import failed', function() { - var xml; - xml = 'test'; - _this.replace.FolderBusinessLayer["import"].andCallFake(function() { - throw new Error(); - }); - _this.scope["import"](xml); - expect(_this.replace.FolderBusinessLayer["import"]).toHaveBeenCalledWith(xml); - return expect(_this.scope.error).toBe(true); - }); - it('should set showall to true if importing', function() { - var xml; - xml = 'test'; - _this.scope["import"](xml); - return expect(_this.ShowAll.getShowAll()).toBe(true); - }); - it('should set showall to true if importing json', function() { - var json; - json = "[\"test\"]"; - _this.scope.importGoogleReader(json); - return expect(_this.ShowAll.getShowAll()).toBe(true); - }); - it('should show an error if the json import failed', function() { - var json; - json = 'test'; - _this.scope.importGoogleReader(json); - return expect(_this.scope.jsonError).toBe(true); - }); - return it('should import json', function() { - var expected, json; - _this.FeedBusinessLayer.importGoogleReader = jasmine.createSpy('googlereader'); - json = "{\"test\": \"abc\"}"; - _this.scope.importGoogleReader(json); - expected = JSON.parse(json); - return expect(_this.FeedBusinessLayer.importGoogleReader).toHaveBeenCalledWith(expected); - }); - }); - -}).call(this); diff --git a/js/build/tests/services/activefeedSpec.js b/js/build/tests/services/activefeedSpec.js deleted file mode 100644 index bba0949ca..000000000 --- a/js/build/tests/services/activefeedSpec.js +++ /dev/null @@ -1,49 +0,0 @@ -// 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 . -*/ - - -(function() { - describe('ActiveFeed', function() { - var _this = this; - beforeEach(module('News')); - beforeEach(inject(function(ActiveFeed, FeedType) { - _this.ActiveFeed = ActiveFeed; - _this.FeedType = FeedType; - return _this.data = { - id: 5, - type: 3 - }; - })); - it('should be Subscriptions by default', function() { - return expect(_this.ActiveFeed.getType()).toBe(_this.FeedType.Subscriptions); - }); - it('should set the correct feed id', function() { - _this.ActiveFeed.handle(_this.data); - return expect(_this.ActiveFeed.getId()).toBe(5); - }); - return it('should set the correct feed type', function() { - _this.ActiveFeed.handle(_this.data); - return expect(_this.ActiveFeed.getType()).toBe(3); - }); - }); - -}).call(this); diff --git a/js/build/tests/services/businesslayer/businesslayerSpec.js b/js/build/tests/services/businesslayer/businesslayerSpec.js deleted file mode 100644 index 8a5a9c1b2..000000000 --- a/js/build/tests/services/businesslayer/businesslayerSpec.js +++ /dev/null @@ -1,88 +0,0 @@ -// 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 . -*/ - - -(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); diff --git a/js/build/tests/services/businesslayer/feedbusinesslayerSpec.js b/js/build/tests/services/businesslayer/feedbusinesslayerSpec.js deleted file mode 100644 index 592b90057..000000000 --- a/js/build/tests/services/businesslayer/feedbusinesslayerSpec.js +++ /dev/null @@ -1,478 +0,0 @@ -// 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 . -*/ - - -(function() { - describe('FeedBusinessLayer', function() { - var _this = this; - beforeEach(module('News')); - beforeEach(module(function($provide) { - _this.setFeedReadSpy = jasmine.createSpy('setFeedRead'); - _this.getItemsSpy = jasmine.createSpy('Get Items'); - _this.persistence = { - setFeedRead: _this.setFeedReadSpy, - getItems: _this.getItemsSpy, - createFeed: function() {}, - test: 'feedbusinesslayer' - }; - _this.imagePath = jasmine.createSpy('imagePath'); - _this.utils = { - imagePath: _this.imagePath - }; - $provide.value('Persistence', _this.persistence); - $provide.value('Utils', _this.utils); - })); - beforeEach(inject(function(FeedBusinessLayer, FeedModel, ItemModel, FeedType, ShowAll, ActiveFeed, _ExistsError, $timeout, NewestItem, $rootScope) { - _this.FeedBusinessLayer = FeedBusinessLayer; - _this.FeedModel = FeedModel; - _this.ItemModel = ItemModel; - _this.FeedType = FeedType; - _this.ShowAll = ShowAll; - _this.ActiveFeed = ActiveFeed; - _this._ExistsError = _ExistsError; - _this.$timeout = $timeout; - _this.NewestItem = NewestItem; - _this.$rootScope = $rootScope; - _this.ShowAll.setShowAll(false); - return _this.ActiveFeed.handle({ - type: _this.FeedType.Folder, - id: 0 - }); - })); - it('should delete feeds', function() { - var data; - data = null; - _this.$rootScope.$on('undoMessage', function(scope, data) { - return data = data; - }); - _this.FeedModel.removeById = jasmine.createSpy('remove').andCallFake(function() { - return { - id: 3, - title: 'test' - }; - }); - _this.persistence.deleteFeed = jasmine.createSpy('deletequery'); - _this.FeedBusinessLayer["delete"](3); - expect(_this.FeedModel.removeById).toHaveBeenCalledWith(3); - return expect(_this.persistence.deleteFeed).toHaveBeenCalledWith(3); - }); - it('should return the number of unread feeds', function() { - var count; - _this.FeedModel.add({ - id: 3, - unreadCount: 134, - url: 'a1' - }); - count = _this.FeedBusinessLayer.getUnreadCount(3); - return expect(count).toBe(134); - }); - it('should return all feeds of a folder', function() { - var feed1, feed2, feed3, feeds; - feed1 = { - id: 3, - unreadCount: 134, - url: 'a1', - folderId: 3 - }; - feed2 = { - id: 4, - unreadCount: 134, - url: 'a2', - folderId: 2 - }; - feed3 = { - id: 5, - unreadCount: 134, - url: 'a3', - folderId: 3 - }; - _this.FeedModel.add(feed1); - _this.FeedModel.add(feed2); - _this.FeedModel.add(feed3); - feeds = _this.FeedBusinessLayer.getFeedsOfFolder(3); - expect(feeds).toContain(feed1); - return expect(feeds).toContain(feed3); - }); - it('should get the correct unread count for folders', function() { - var count; - _this.FeedModel.add({ - id: 3, - unreadCount: 134, - folderId: 3, - url: 'a1' - }); - _this.FeedModel.add({ - id: 5, - unreadCount: 2, - folderId: 2, - url: 'a2' - }); - _this.FeedModel.add({ - id: 1, - unreadCount: 12, - folderId: 5, - url: 'a3' - }); - _this.FeedModel.add({ - id: 2, - unreadCount: 35, - folderId: 3, - url: 'a4' - }); - count = _this.FeedBusinessLayer.getFolderUnreadCount(3); - return expect(count).toBe(169); - }); - it('should not mark feed read when no highest item id', function() { - _this.FeedModel.add({ - id: 5, - unreadCount: 2, - folderId: 2, - url: 'a1' - }); - _this.persistence.setFeedRead = jasmine.createSpy('setFeedRead'); - _this.FeedBusinessLayer.markRead(5); - return expect(_this.persistence.setFeedRead).not.toHaveBeenCalled(); - }); - it('should mark feed as read', function() { - var item1, item2; - _this.NewestItem.handle(25); - _this.ActiveFeed.handle({ - type: _this.FeedType.Feed, - id: 5 - }); - _this.persistence.setFeedRead = jasmine.createSpy('setFeedRead'); - _this.FeedModel.add({ - id: 5, - unreadCount: 2, - folderId: 2, - url: 'a1' - }); - item1 = { - id: 3, - feedId: 5, - guidHash: 'a3', - status: 0 - }; - _this.ItemModel.add(item1); - item1.setUnread(); - item2 = { - id: 2, - feedId: 3, - guidHash: 'a3', - status: 0 - }; - _this.ItemModel.add(item2); - item2.setUnread(); - _this.FeedBusinessLayer.markRead(5); - expect(_this.persistence.setFeedRead).toHaveBeenCalledWith(5, 25); - expect(_this.FeedModel.getById(5).unreadCount).toBe(0); - expect(item1.isRead()).toBe(true); - return expect(item2.isRead()).toBe(false); - }); - it('should get the correct unread count for subscribtions', function() { - var count; - _this.FeedModel.add({ - id: 3, - unreadCount: 134, - url: 'a1' - }); - _this.FeedModel.add({ - id: 5, - unreadCount: 2, - url: 'a2' - }); - count = _this.FeedBusinessLayer.getAllUnreadCount(); - return expect(count).toBe(136); - }); - it('should return the correct number of feeds', function() { - var count; - _this.FeedModel.add({ - id: 3, - unreadCount: 134, - url: 'a1' - }); - _this.FeedModel.add({ - id: 5, - unreadCount: 2, - url: 'a2' - }); - count = _this.FeedBusinessLayer.getNumberOfFeeds(); - return expect(count).toBe(2); - }); - it('should be visible if its active', function() { - _this.ActiveFeed.handle({ - type: _this.FeedType.Feed, - id: 3 - }); - return expect(_this.FeedBusinessLayer.isVisible(3)).toBe(true); - }); - it('should be visible if show all is true', function() { - expect(_this.FeedBusinessLayer.isVisible(3)).toBe(false); - _this.ShowAll.setShowAll(true); - return expect(_this.FeedBusinessLayer.isVisible(3)).toBe(true); - }); - it('should be visible if unreadcount bigger than 0', function() { - _this.FeedModel.add({ - id: 2, - unreadCount: 134, - url: 'a1' - }); - return expect(_this.FeedBusinessLayer.isVisible(2)).toBe(true); - }); - it('should not move the feed to a new folder', function() { - _this.persistence.moveFeed = jasmine.createSpy('Move feed'); - _this.FeedModel.add({ - id: 2, - unreadCount: 134, - url: 'a1', - folderId: 3 - }); - _this.FeedBusinessLayer.move(2, 4); - expect(_this.persistence.moveFeed).toHaveBeenCalledWith(2, 4); - return expect(_this.FeedModel.getById(2).folderId).toBe(4); - }); - it('should not move the feed to the same folder', function() { - _this.persistence.moveFeed = jasmine.createSpy('Move feed'); - _this.FeedModel.add({ - id: 2, - unreadCount: 134, - url: 'a1', - folderId: 3 - }); - _this.FeedBusinessLayer.move(2, 3); - return expect(_this.persistence.moveFeed).not.toHaveBeenCalled(); - }); - it('should set the show all setting', function() { - _this.persistence.userSettingsReadShow = jasmine.createSpy('Show All'); - _this.FeedBusinessLayer.setShowAll(true); - return expect(_this.persistence.userSettingsReadShow).toHaveBeenCalled(); - }); - it('should set the hide read setting', function() { - _this.persistence.userSettingsReadHide = jasmine.createSpy('Hide Read'); - _this.FeedBusinessLayer.setShowAll(false); - return expect(_this.persistence.userSettingsReadHide).toHaveBeenCalled(); - }); - it('should return all feeds', function() { - var item1, item2; - item1 = { - id: 2, - unreadCount: 134, - url: 'a1', - folderId: 3 - }; - item2 = { - id: 4, - unreadCount: 134, - url: 'a2', - folderId: 3 - }; - _this.FeedModel.add(item1); - _this.FeedModel.add(item2); - expect(_this.FeedBusinessLayer.getAll()).toContain(item1); - return expect(_this.FeedBusinessLayer.getAll()).toContain(item2); - }); - it('should return if ShowAll is set', function() { - _this.persistence.userSettingsReadShow = jasmine.createSpy('Show All'); - expect(_this.FeedBusinessLayer.isShowAll()).toBe(false); - _this.FeedBusinessLayer.setShowAll(true); - return expect(_this.FeedBusinessLayer.isShowAll()).toBe(true); - }); - it('should return all feeds of a folder', function() { - var folders, item1, item2, item3; - item1 = { - id: 2, - unreadCount: 134, - url: 'a1', - folderId: 3 - }; - item2 = { - id: 4, - unreadCount: 134, - url: 'a2', - folderId: 2 - }; - item3 = { - id: 5, - unreadCount: 134, - url: 'a3', - folderId: 3 - }; - _this.FeedModel.add(item1); - _this.FeedModel.add(item2); - _this.FeedModel.add(item3); - folders = _this.FeedBusinessLayer.getFeedsOfFolder(3); - expect(folders).toContain(item1); - return expect(folders).toContain(item3); - }); - it('should return the correct feed link', function() { - var item2; - item2 = { - id: 4, - unreadCount: 134, - url: 'a2', - folderId: 3, - link: 'test.com' - }; - _this.FeedModel.add(item2); - return expect(_this.FeedBusinessLayer.getFeedLink(4)).toBe('test.com'); - }); - it('should not create a feed if it already exists', function() { - var item1; - item1 = { - url: 'http://john' - }; - _this.FeedModel.add(item1); - expect(function() { - return _this.FeedBusinessLayer.create('john'); - }).toThrow(new _this._ExistsError('Exists already')); - return expect(function() { - return _this.FeedBusinessLayer.create('johns'); - }).not.toThrow(new _this._ExistsError('Exists already')); - }); - it('should not create feeds that are empty', function() { - return expect(function() { - return _this.FeedBusinessLayer.create(' '); - }).toThrow(new Error('Url must not be empty')); - }); - it('should create a feed before theres a response from the server', function() { - _this.FeedBusinessLayer.create('johns'); - return expect(_this.FeedModel.size()).toBe(1); - }); - it('should set a title and an url to the newly created feed', function() { - var feed, url; - url = 'www.google.de'; - _this.FeedBusinessLayer.create(url); - feed = _this.FeedModel.getByUrl('http://' + url); - expect(feed.title).toBe('http://www.google.de'); - expect(feed.url).toBe('http://' + url); - expect(feed.folderId).toBe(0); - expect(feed.unreadCount).toBe(0); - return expect(_this.imagePath).toHaveBeenCalledWith('core', 'loading.gif'); - }); - it('should not add http when it already is at the start of created feed', function() { - var feed, url; - url = 'https://www.google.de'; - _this.FeedBusinessLayer.create(url); - feed = _this.FeedModel.getByUrl(url); - return expect(feed.url).toBe(url); - }); - it('should make a create feed request', function() { - _this.persistence.createFeed = jasmine.createSpy('add feed'); - _this.FeedBusinessLayer.create(' johns '); - return expect(_this.persistence.createFeed).toHaveBeenCalledWith('http://johns', 0, jasmine.any(Function)); - }); - it('should call the onSuccess function on response status ok', function() { - var onSuccess; - onSuccess = jasmine.createSpy('Success'); - _this.persistence.createFeed = jasmine.createSpy('add feed'); - _this.persistence.createFeed.andCallFake(function(folderName, parentId, success) { - _this.response = { - status: 'ok', - data: 'hi' - }; - return success(_this.response); - }); - _this.FeedBusinessLayer.create(' johns ', 0, onSuccess); - return expect(onSuccess).toHaveBeenCalledWith(_this.response.data); - }); - it('should call the handle a response error when creating a folder', function() { - var onFailure, onSuccess; - onSuccess = jasmine.createSpy('Success'); - onFailure = jasmine.createSpy('Failure'); - _this.persistence.createFeed = jasmine.createSpy('add feed'); - _this.persistence.createFeed.andCallFake(function(folderName, parentId, success) { - _this.response = { - status: 'error', - msg: 'this is an error' - }; - return success(_this.response); - }); - _this.FeedBusinessLayer.create(' johns ', 0, onSuccess, onFailure); - expect(onSuccess).not.toHaveBeenCalled(); - expect(onFailure).toHaveBeenCalled(); - return expect(_this.FeedModel.getByUrl('http://johns').error).toBe(_this.response.msg); - }); - it('should mark a feed error as read by removing it', function() { - _this.FeedModel.add({ - id: 3, - url: 'john' - }); - _this.FeedBusinessLayer.markErrorRead('john'); - expect(_this.FeedModel.size()).toBe(0); - return expect(_this.FeedModel.getByUrl('john')).toBe(void 0); - }); - it('should not import google reader json', function() { - var imported, json; - _this.persistence.importGoogleReader = jasmine.createSpy('importGoogleReader'); - json = { - "test": "hi" - }; - _this.FeedBusinessLayer.importGoogleReader(json); - imported = _this.FeedModel.getByUrl('http://owncloud/googlereader'); - expect(imported.title).toBe('Google Reader'); - expect(imported.folderId).toBe(0); - return expect(imported.unreadCount).toBe(0); - }); - it('should not create a google reader feed if it already exists', function() { - var imported, json; - _this.persistence.importGoogleReader = jasmine.createSpy('importGoogleReader'); - _this.FeedModel.add({ - id: 3, - url: 'http://owncloud/googlereader' - }); - json = { - "test": "hi" - }; - _this.FeedBusinessLayer.importGoogleReader(json); - imported = _this.FeedModel.getByUrl('http://owncloud/googlereader'); - return expect(imported.folderId).not.toBeDefined(); - }); - return it('should create an import google reader request', function() { - var json, returned; - returned = { - data: { - feeds: [ - { - id: 3, - url: 'hi' - } - ] - } - }; - _this.persistence.getItems = jasmine.createSpy('importGoogleReader'); - _this.persistence.importGoogleReader = jasmine.createSpy('importGoogleReader'); - _this.persistence.importGoogleReader.andCallFake(function(data, onSuccess) { - _this.FeedModel.handle(returned.data.feeds); - return onSuccess(returned); - }); - json = { - "test": "hi" - }; - _this.FeedBusinessLayer.importGoogleReader(json); - expect(_this.persistence.importGoogleReader).toHaveBeenCalledWith(json, jasmine.any(Function)); - expect(_this.persistence.getItems).toHaveBeenCalledWith(_this.FeedType.Feed, returned.data.feeds[0].id, 0); - expect(_this.ActiveFeed.getId()).toBe(returned.data.feeds[0].id); - return expect(_this.ActiveFeed.getType()).toBe(_this.FeedType.Feed); - }); - }); - -}).call(this); diff --git a/js/build/tests/services/businesslayer/folderbusinesslayerSpec.js b/js/build/tests/services/businesslayer/folderbusinesslayerSpec.js deleted file mode 100644 index be4e3cd3a..000000000 --- a/js/build/tests/services/businesslayer/folderbusinesslayerSpec.js +++ /dev/null @@ -1,577 +0,0 @@ -// 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 . -*/ - - -(function() { - describe('FolderBusinessLayer', function() { - var _this = this; - beforeEach(module('News')); - beforeEach(module(function($provide) { - _this.persistence = { - test: 'folderbusinesslayer' - }; - _this.imagePath = jasmine.createSpy('imagePath'); - _this.utils = { - imagePath: _this.imagePath - }; - $provide.value('Persistence', _this.persistence); - $provide.value('Utils', _this.utils); - })); - beforeEach(inject(function(FolderBusinessLayer, FolderModel, FeedModel, ShowAll, ActiveFeed, FeedType, _ExistsError, $timeout, NewestItem, ItemModel, $rootScope) { - _this.FolderBusinessLayer = FolderBusinessLayer; - _this.FolderModel = FolderModel; - _this.FeedModel = FeedModel; - _this.ShowAll = ShowAll; - _this.ActiveFeed = ActiveFeed; - _this.FeedType = FeedType; - _this._ExistsError = _ExistsError; - _this.$timeout = $timeout; - _this.NewestItem = NewestItem; - _this.ItemModel = ItemModel; - _this.$rootScope = $rootScope; - _this.ShowAll.setShowAll(false); - return _this.ActiveFeed.handle({ - type: _this.FeedType.Feed, - id: 0 - }); - })); - it('should delete folders', function() { - var data; - data = null; - _this.$rootScope.$on('undoMessage', function(scope, data) { - return data = data; - }); - _this.FeedModel.add({ - id: 5, - unreadCount: 2, - folderId: 3, - url: 'a1' - }); - _this.FolderModel.removeById = jasmine.createSpy('remove').andCallFake(function() { - return { - id: 3, - name: 'test' - }; - }); - _this.FeedModel.removeById = jasmine.createSpy('remove').andCallFake(function() { - return { - id: 5, - name: 'test', - folderId: 3 - }; - }); - _this.persistence.deleteFolder = jasmine.createSpy('deletequery'); - _this.FolderBusinessLayer["delete"](3); - expect(_this.FolderModel.removeById).toHaveBeenCalledWith(3); - expect(_this.FeedModel.removeById).toHaveBeenCalledWith(5); - return expect(_this.persistence.deleteFolder).toHaveBeenCalledWith(3); - }); - it('should return true when folder has feeds', function() { - _this.FeedModel.add({ - id: 5, - unreadCount: 2, - folderId: 2, - url: 'a1' - }); - expect(_this.FolderBusinessLayer.hasFeeds(3)).toBeFalsy(); - _this.FeedModel.add({ - id: 2, - unreadCount: 35, - folderId: 3, - url: 'a2' - }); - return expect(_this.FolderBusinessLayer.hasFeeds(3)).toBeTruthy(); - }); - it('should toggle folder', function() { - _this.persistence.openFolder = jasmine.createSpy('open'); - _this.persistence.collapseFolder = jasmine.createSpy('collapse'); - _this.FolderModel.add({ - id: 3, - opened: false, - name: 'ho' - }); - _this.FolderBusinessLayer.toggleFolder(4); - expect(_this.FolderModel.getById(3).opened).toBeFalsy(); - _this.FolderBusinessLayer.toggleFolder(3); - expect(_this.FolderModel.getById(3).opened).toBeTruthy(); - expect(_this.persistence.openFolder).toHaveBeenCalledWith(3); - _this.FolderBusinessLayer.toggleFolder(3); - expect(_this.FolderModel.getById(3).opened).toBeFalsy(); - return expect(_this.persistence.collapseFolder).toHaveBeenCalledWith(3); - }); - it('should mark folder as read', function() { - var item1, item2; - _this.NewestItem.handle(25); - _this.persistence.setFolderRead = jasmine.createSpy('setFeedRead'); - item1 = { - id: 3, - feedId: 5, - guidHash: 'a3', - status: 0 - }; - _this.ItemModel.add(item1); - item1.setUnread(); - item2 = { - id: 2, - feedId: 3, - guidHash: 'a3', - status: 0 - }; - _this.ItemModel.add(item2); - item2.setUnread(); - _this.FolderModel.add({ - id: 3, - opened: false, - name: 'ho' - }); - _this.FeedModel.add({ - id: 3, - unreadCount: 134, - folderId: 3, - url: 'a1' - }); - _this.FeedModel.add({ - id: 5, - unreadCount: 2, - folderId: 2, - url: 'a2' - }); - _this.FeedModel.add({ - id: 1, - unreadCount: 12, - folderId: 3, - url: 'a3' - }); - _this.FolderBusinessLayer.markRead(3); - expect(_this.FeedModel.getById(3).unreadCount).toBe(0); - expect(_this.FeedModel.getById(1).unreadCount).toBe(0); - expect(_this.FeedModel.getById(5).unreadCount).toBe(2); - expect(item1.isRead()).toBe(false); - expect(item2.isRead()).toBe(true); - return expect(_this.persistence.setFolderRead).toHaveBeenCalledWith(3, 25); - }); - it('should not mark folder read when no highest item id', function() { - _this.FolderModel.add({ - id: 5, - opened: false, - name: 'ho' - }); - _this.persistence.setFolderRead = jasmine.createSpy('setFolderRead'); - _this.FolderBusinessLayer.markRead(5); - return expect(_this.persistence.setFolderRead).not.toHaveBeenCalled(); - }); - it('should get the correct unread count', function() { - _this.FeedModel.add({ - id: 5, - unreadCount: 2, - folderId: 2, - url: 'a1' - }); - _this.FeedModel.add({ - id: 6, - unreadCount: 3, - folderId: 3, - url: 'a2' - }); - _this.FeedModel.add({ - id: 7, - unreadCount: 4, - folderId: 2, - url: 'a3' - }); - return expect(_this.FolderBusinessLayer.getUnreadCount(2)).toBe(6); - }); - it('should be visible if show all is true', function() { - expect(_this.FolderBusinessLayer.isVisible(3)).toBe(false); - _this.ShowAll.setShowAll(true); - return expect(_this.FolderBusinessLayer.isVisible(3)).toBe(true); - }); - it('should be visible if its active', function() { - _this.ActiveFeed.handle({ - type: _this.FeedType.Folder, - id: 3 - }); - return expect(_this.FolderBusinessLayer.isVisible(3)).toBe(true); - }); - it('should be visible if one of its subfeeds is active', function() { - _this.FeedModel.add({ - id: 5, - unreadCount: 0, - folderId: 2, - url: 'a1' - }); - _this.FeedModel.add({ - id: 6, - unreadCount: 0, - folderId: 3, - url: 'a2' - }); - _this.FeedModel.add({ - id: 7, - unreadCount: 0, - folderId: 2, - url: 'a3' - }); - _this.ActiveFeed.handle({ - type: _this.FeedType.Feed, - id: 6 - }); - return expect(_this.FolderBusinessLayer.isVisible(3)).toBe(true); - }); - it('should be visible if showAll is false and it has unread items', function() { - _this.FeedModel.add({ - id: 5, - unreadCount: 2, - folderId: 2, - url: 'a1' - }); - _this.FeedModel.add({ - id: 6, - unreadCount: 3, - folderId: 3, - url: 'a2' - }); - _this.FeedModel.add({ - id: 7, - unreadCount: 4, - folderId: 2, - url: 'a3' - }); - _this.ActiveFeed.handle({ - type: _this.FeedType.Folder, - id: 2 - }); - return expect(_this.FolderBusinessLayer.isVisible(3)).toBe(true); - }); - it('should return all folders', function() { - var item1, item2; - item1 = { - id: 3, - open: false, - name: 'ho' - }; - item2 = { - id: 4, - open: true, - name: 'hod' - }; - _this.FolderModel.add(item1); - _this.FolderModel.add(item2); - expect(_this.FolderBusinessLayer.getAll()).toContain(item1); - return expect(_this.FolderBusinessLayer.getAll()).toContain(item2); - }); - it('should not create a folder if it already exists', function() { - var item1; - item1 = { - id: 4, - open: true, - name: 'john' - }; - _this.FolderModel.add(item1); - expect(function() { - return _this.FolderBusinessLayer.create('john'); - }).toThrow(new _this._ExistsError('Exists already')); - return expect(function() { - return _this.FolderBusinessLayer.create('johns'); - }).not.toThrow(new _this._ExistsError('Exists already')); - }); - it('should not create folders that are empty', function() { - return expect(function() { - return _this.FolderBusinessLayer.create(' '); - }).toThrow(new Error('Folder name must not be empty')); - }); - it('should create a folder before theres a response from the server', function() { - _this.persistence.createFolder = jasmine.createSpy('create folder'); - _this.FolderBusinessLayer.create('johns'); - expect(_this.FolderModel.size()).toBe(1); - return expect(_this.FolderModel.getByName('johns').opened).toBe(true); - }); - it('should make a create folder request', function() { - _this.persistence.createFolder = jasmine.createSpy('add folder'); - _this.FolderBusinessLayer.create(' johns '); - return expect(_this.persistence.createFolder).toHaveBeenCalledWith('johns', 0, jasmine.any(Function)); - }); - it('should call the onSuccess function on response status ok', function() { - var onSuccess; - onSuccess = jasmine.createSpy('Success'); - _this.persistence.createFolder = jasmine.createSpy('add folder'); - _this.persistence.createFolder.andCallFake(function(folderName, parentId, success) { - _this.response = { - status: 'ok', - data: 'jooo' - }; - return success(_this.response); - }); - _this.FolderBusinessLayer.create(' johns ', onSuccess); - return expect(onSuccess).toHaveBeenCalledWith(_this.response.data); - }); - it('should call the handle a response error when creating a folder', function() { - var onFailure, onSuccess; - onSuccess = jasmine.createSpy('Success'); - onFailure = jasmine.createSpy('Failure'); - _this.persistence.createFolder = jasmine.createSpy('add folder'); - _this.persistence.createFolder.andCallFake(function(folderName, parentId, success) { - _this.response = { - status: 'error', - msg: 'this is an error' - }; - return success(_this.response); - }); - _this.FolderBusinessLayer.create(' johns ', onSuccess, onFailure); - expect(onSuccess).not.toHaveBeenCalled(); - expect(onFailure).toHaveBeenCalled(); - return expect(_this.FolderModel.getByName('johns').error).toBe(_this.response.msg); - }); - it('should mark a folder error as read by removing it', function() { - _this.FolderModel.add({ - id: 3, - name: 'john' - }); - _this.FolderBusinessLayer.markErrorRead('John'); - expect(_this.FolderModel.size()).toBe(0); - return expect(_this.FolderModel.getByName('john')).toBe(void 0); - }); - it('should return the corret folder for id', function() { - var item; - item = { - id: 3, - name: 'john' - }; - _this.FolderModel.add(item); - return expect(_this.FolderBusinessLayer.getById(3)).toBe(item); - }); - it('should open a folder', function() { - _this.persistence.openFolder = jasmine.createSpy('open'); - _this.FolderModel.add({ - id: 3, - opened: false, - name: 'ho' - }); - _this.FolderBusinessLayer.open(3); - expect(_this.FolderModel.getById(3).opened).toBeTruthy(); - return expect(_this.persistence.openFolder).toHaveBeenCalledWith(3); - }); - it('should not import on empty opml', function() { - var xml; - _this.persistence.createFolder = jasmine.createSpy('create folder'); - _this.persistence.createFeed = jasmine.createSpy('create feed'); - xml = '\ - \ - \ - \ - \ - NewsBlur Feeds\ - \ - \ - 2013-03-14 16:44:01.356965\ - \ - \ - 2013-03-14 16:44:01.356965\ - \ - \ - \ -\ - \ - '; - _this.FolderBusinessLayer["import"](xml); - expect(_this.persistence.createFolder).not.toHaveBeenCalled(); - return expect(_this.persistence.createFeed).not.toHaveBeenCalled(); - }); - it('should import a folder', function() { - var xml; - _this.persistence.createFolder = jasmine.createSpy('create folder'); - _this.persistence.createFeed = jasmine.createSpy('create feed'); - xml = '\ - \ - \ - \ - \ - NewsBlur Feeds\ - \ - \ - 2013-03-14 16:44:01.356965\ - \ - \ - 2013-03-14 16:44:01.356965\ - \ - \ - \ - \ - \ - \ - '; - _this.FolderBusinessLayer["import"](xml); - expect(_this.persistence.createFolder).toHaveBeenCalledWith('test', 0, jasmine.any(Function)); - return expect(_this.persistence.createFeed).not.toHaveBeenCalled(); - }); - it('should import a feed', function() { - var xml; - _this.persistence.createFolder = jasmine.createSpy('create folder'); - _this.persistence.createFeed = jasmine.createSpy('create feed'); - xml = '\ - \ - \ - \ - \ - NewsBlur Feeds\ - \ - \ - 2013-03-14 16:44:01.356965\ - \ - \ - 2013-03-14 16:44:01.356965\ - \ - \ - \ - \ - \ - '; - _this.FolderBusinessLayer["import"](xml); - expect(_this.persistence.createFolder).not.toHaveBeenCalled(); - return expect(_this.persistence.createFeed).toHaveBeenCalledWith('http://worrydream.com/feed.xml', 0, jasmine.any(Function)); - }); - it('should import nested folders', function() { - var xml; - _this.persistence.createFolder = jasmine.createSpy('create folder'); - _this.persistence.createFolder.andCallFake(function(name, parentId, onSuccess) { - var data; - data = { - data: { - folders: [ - { - id: 3 - } - ] - } - }; - return onSuccess(data); - }); - _this.persistence.createFeed = jasmine.createSpy('create feed'); - xml = '\ - \ - \ - \ - \ - NewsBlur Feeds\ - \ - \ - 2013-03-14 16:44:01.356965\ - \ - \ - 2013-03-14 16:44:01.356965\ - \ - \ - \ - \ - \ - \ - \ - '; - _this.FolderBusinessLayer["import"](xml); - expect(_this.persistence.createFolder).toHaveBeenCalledWith('Design', 0, jasmine.any(Function)); - return expect(_this.persistence.createFeed).toHaveBeenCalledWith('http://worrydream.com/feed.xml', 3, jasmine.any(Function)); - }); - it('should use an existing folder when importing a folder', function() { - var folder, xml; - _this.persistence.createFolder = jasmine.createSpy('create folder'); - _this.persistence.createFeed = jasmine.createSpy('create feed'); - _this.persistence.openFolder = jasmine.createSpy('open'); - folder = { - id: 2, - name: 'design', - opened: false - }; - _this.FolderModel.add(folder); - xml = '\ - \ - \ - \ - \ - NewsBlur Feeds\ - \ - \ - 2013-03-14 16:44:01.356965\ - \ - \ - 2013-03-14 16:44:01.356965\ - \ - \ - \ - \ - \ - \ - \ - '; - _this.FolderBusinessLayer["import"](xml); - expect(_this.persistence.createFolder).not.toHaveBeenCalled(); - expect(_this.persistence.createFeed).toHaveBeenCalledWith('http://worrydream.com/feed.xml', 2, jasmine.any(Function)); - expect(folder.opened).toBe(true); - return expect(_this.persistence.openFolder).toHaveBeenCalled(); - }); - return it('should not import a feed if it already exists', function() { - var xml; - _this.persistence.createFolder = jasmine.createSpy('create folder'); - _this.persistence.createFeed = jasmine.createSpy('create feed'); - _this.FeedModel.add({ - url: 'http://worrydream.com/feed.xml' - }); - xml = '\ - \ - \ - \ - \ - NewsBlur Feeds\ - \ - \ - 2013-03-14 16:44:01.356965\ - \ - \ - 2013-03-