summaryrefslogtreecommitdiffstats
path: root/js/build/tests/services/models
diff options
context:
space:
mode:
Diffstat (limited to 'js/build/tests/services/models')
-rw-r--r--js/build/tests/services/models/feedmodelSpec.js175
-rw-r--r--js/build/tests/services/models/foldermodelSpec.js140
-rw-r--r--js/build/tests/services/models/itemmodelSpec.js160
3 files changed, 0 insertions, 475 deletions
diff --git a/js/build/tests/services/models/feedmodelSpec.js b/js/build/tests/services/models/feedmodelSpec.js
deleted file mode 100644
index a910e4aaf..000000000
--- a/js/build/tests/services/models/feedmodelSpec.js
+++ /dev/null
@@ -1,175 +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 <http://www.gnu.org/licenses/>.
-*/
-
-
-(function() {
- describe('FeedModel', 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);
- }));
- beforeEach(inject(function(FeedModel, _Model) {
- _this.FeedModel = FeedModel;
- _this._Model = _Model;
- }));
- it('should extend _Model', function() {
- return expect(_this.FeedModel instanceof _this._Model).toBeTruthy();
- });
- it('should bind an imagepath to the item if the url is empty', function() {
- var item;
- item = {
- id: 3,
- faviconLink: null,
- url: 'hi'
- };
- _this.FeedModel.add(item);
- return expect(_this.utils.imagePath).toHaveBeenCalledWith('news', 'rss.svg');
- });
- it('should add feeds without id', function() {
- var item, item2;
- item = {
- faviconLink: null,
- url: 'hi'
- };
- _this.FeedModel.add(item);
- item2 = {
- faviconLink: null,
- url: 'his'
- };
- _this.FeedModel.add(item2);
- expect(_this.FeedModel.getByUrl('hi')).toBe(item);
- return expect(_this.FeedModel.size()).toBe(2);
- });
- it('should clear the url cache', function() {
- var item;
- item = {
- faviconLink: null,
- url: 'hi'
- };
- _this.FeedModel.add(item);
- _this.FeedModel.clear();
- expect(_this.FeedModel.getByUrl('hi')).toBe(void 0);
- return expect(_this.FeedModel.size()).toBe(0);
- });
- it('should delete items from the fodername cache', function() {
- var item;
- item = {
- id: 3,
- faviconLink: null,
- url: 'hi'
- };
- _this.FeedModel.add(item);
- expect(_this.FeedModel.size()).toBe(1);
- _this.FeedModel.removeById(3);
- expect(_this.FeedModel.getByUrl('hi')).toBe(void 0);
- return expect(_this.FeedModel.size()).toBe(0);
- });
- it('should update the id if an update comes in with an id', function() {
- var item, item2;
- item = {
- faviconLink: null,
- url: 'hi',
- test: 'heheh'
- };
- _this.FeedModel.add(item);
- item2 = {
- id: 3,
- faviconLink: null,
- url: 'hi',
- test: 'hoho'
- };
- _this.FeedModel.add(item2);
- expect(_this.FeedModel.getByUrl('hi').id).toBe(3);
- expect(_this.FeedModel.getByUrl('hi').test).toBe('hoho');
- expect(_this.FeedModel.getById(3).id).toBe(3);
- expect(_this.FeedModel.getById(3).test).toBe('hoho');
- return expect(_this.FeedModel.size()).toBe(1);
- });
- it('should update normally', function() {
- var item, item2;
- item = {
- id: 3,
- faviconLink: null,
- url: 'hi',
- test: 'heheh'
- };
- _this.FeedModel.add(item);
- item2 = {
- id: 3,
- faviconLink: null,
- url: 'his',
- test: 'hoho'
- };
- _this.FeedModel.add(item2);
- expect(_this.FeedModel.getByUrl('hi')).toBe(void 0);
- expect(_this.FeedModel.getByUrl('his').id).toBe(3);
- expect(_this.FeedModel.getByUrl('his').test).toBe('hoho');
- expect(_this.FeedModel.getById(3).test).toBe('hoho');
- return expect(_this.FeedModel.size()).toBe(1);
- });
- it('should clear invalidate the query cache on adding folder with name', function() {
- var item, item2;
- item = {
- faviconLink: null,
- url: 'hi',
- test: 'heheh',
- folderId: 0
- };
- expect(_this.FeedModel.getAllOfFolder(0).length).toBe(0);
- _this.FeedModel.add(item, false);
- expect(_this.FeedModel.getAllOfFolder(0).length).toBe(0);
- item2 = {
- faviconLink: null,
- url: 'his',
- test: 'heheh',
- folderId: 0
- };
- _this.FeedModel.add(item2);
- return expect(_this.FeedModel.getAllOfFolder(0).length).toBe(2);
- });
- return it('should only update feeds that contain only an id but no url', function() {
- var item, item2;
- item = {
- id: 3,
- unreadCount: 232
- };
- _this.FeedModel.add(item);
- expect(_this.FeedModel.size()).toBe(0);
- item2 = {
- id: 3,
- unreadCount: 2,
- faviconLink: null,
- url: 'his'
- };
- _this.FeedModel.add(item2);
- _this.FeedModel.add(item);
- expect(_this.FeedModel.size()).toBe(1);
- return expect(_this.FeedModel.getById(3).unreadCount).toBe(232);
- });
- });
-
-}).call(this);
diff --git a/js/build/tests/services/models/foldermodelSpec.js b/js/build/tests/services/models/foldermodelSpec.js
deleted file mode 100644
index adcd4db47..000000000
--- a/js/build/tests/services/models/foldermodelSpec.js
+++ /dev/null
@@ -1,140 +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 <http://www.gnu.org/licenses/>.
-*/
-
-
-(function() {
- describe('FolderModel', function() {
- var _this = this;
- beforeEach(module('News'));
- beforeEach(inject(function(FolderModel, _Model, _EqualQuery) {
- _this.FolderModel = FolderModel;
- _this._Model = _Model;
- _this._EqualQuery = _EqualQuery;
- }));
- it('should extend model', function() {
- return expect(_this.FolderModel instanceof _this._Model).toBeTruthy();
- });
- it('should add folders without id but name if they dont exist yet', function() {
- var item, item1;
- item = {
- name: 'Hi'
- };
- _this.FolderModel.add(item);
- item1 = {
- name: 'His'
- };
- _this.FolderModel.add(item1);
- expect(_this.FolderModel.getByName('hi')).toBe(item);
- return expect(_this.FolderModel.size()).toBe(2);
- });
- it('should clear the fodername cache', function() {
- var item;
- item = {
- name: 'Hi'
- };
- _this.FolderModel.add(item);
- _this.FolderModel.clear();
- expect(_this.FolderModel.getByName('hi')).toBe(void 0);
- return expect(_this.FolderModel.size()).toBe(0);
- });
- it('should delete items from the fodername cache', function() {
- var item;
- item = {
- id: 3,
- name: 'Hi'
- };
- _this.FolderModel.add(item);
- _this.FolderModel.removeById(3);
- expect(_this.FolderModel.getByName('hi')).toBe(void 0);
- return expect(_this.FolderModel.size()).toBe(0);
- });
- it('should update by foldername', function() {
- var item, item2;
- item = {
- name: 'Hi'
- };
- _this.FolderModel.add(item);
- item2 = {
- name: 'hi',
- test: 'hoho'
- };
- _this.FolderModel.add(item2);
- expect(_this.FolderModel.getByName('hi').test).toBe('hoho');
- return expect(_this.FolderModel.size()).toBe(1);
- });
- it('should update the id if an update comes in with an id', function() {
- var item, item2;
- item = {
- name: 'Tony'
- };
- _this.FolderModel.add(item);
- item2 = {
- id: 3,
- name: 'tony',
- test: 'hoho'
- };
- _this.FolderModel.add(item2);
- expect(_this.FolderModel.getByName('Tony').id).toBe(3);
- expect(_this.FolderModel.getByName('Tony').test).toBe('hoho');
- expect(_this.FolderModel.getById(3).id).toBe(3);
- expect(_this.FolderModel.getById(3).test).toBe('hoho');
- return expect(_this.FolderModel.size()).toBe(1);
- });
- it('should update normally', function() {
- var item, item2;
- item = {
- id: 3,
- name: 'His'
- };
- _this.FolderModel.add(item);
- item2 = {
- id: 3,
- name: 'hobo',
- test: 'hoho'
- };
- _this.FolderModel.add(item2);
- expect(_this.FolderModel.getByName('His')).toBe(void 0);
- expect(_this.FolderModel.getByName('Hobo').id).toBe(3);
- expect(_this.FolderModel.getByName('Hobo').test).toBe('hoho');
- expect(_this.FolderModel.getById(3).test).toBe('hoho');
- return expect(_this.FolderModel.size()).toBe(1);
- });
- return it('should clear invalidate the query cache on adding folder with name', function() {
- var item, item2, query;
- item = {
- name: 'name1',
- test: 'hi'
- };
- query = new _this._EqualQuery('test', 'hi');
- expect(_this.FolderModel.get(query).length).toBe(0);
- _this.FolderModel.add(item, false);
- expect(_this.FolderModel.get(query).length).toBe(0);
- item2 = {
- name: 'name',
- test: 'hi'
- };
- _this.FolderModel.add(item2);
- return expect(_this.FolderModel.get(query).length).toBe(2);
- });
- });
-
-}).call(this);
diff --git a/js/build/tests/services/models/itemmodelSpec.js b/js/build/tests/services/models/itemmodelSpec.js
deleted file mode 100644
index 929163689..000000000
--- a/js/build/tests/services/models/itemmodelSpec.js
+++ /dev/null
@@ -1,160 +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 <http://www.gnu.org/licenses/>.
-*/
-
-
-(function() {
- describe('ItemModel', function() {
- var _this = this;
- beforeEach(module('News'));
- beforeEach(inject(function(ItemModel, _Model) {
- _this.ItemModel = ItemModel;
- _this._Model = _Model;
- }));
- it('should extend model', function() {
- return expect(_this.ItemModel instanceof _this._Model).toBeTruthy();
- });
- it('should also update items with the same feed id and guidhash', function() {
- var item1, item2, item3, item4;
- item1 = {
- id: 4,
- guidHash: 'abc',
- feedId: 3
- };
- _this.ItemModel.add(item1);
- expect(_this.ItemModel.getById(4)).toBe(item1);
- item2 = {
- id: 4,
- guidHash: 'abc',
- feedId: 4
- };
- _this.ItemModel.add(item2);
- expect(_this.ItemModel.size()).toBe(1);
- item3 = {
- id: 5,
- guidHash: 'abc',
- feedId: 6
- };
- _this.ItemModel.add(item3);
- expect(_this.ItemModel.size()).toBe(2);
- item4 = {
- id: 3,
- guidHash: 'abc',
- feedId: 6
- };
- _this.ItemModel.add(item4);
- expect(_this.ItemModel.getById(3).guidHash).toBe(item4.guidHash);
- expect(_this.ItemModel.getById(3).feedId).toBe(item4.feedId);
- expect(_this.ItemModel.getById(3).id).toBe(item4.id);
- expect(_this.ItemModel.getById(5)).toBe(void 0);
- return expect(_this.ItemModel.size()).toBe(2);
- });
- it('should also remove the feed from the url cache when its removed', function() {
- var item;
- item = {
- id: 4,
- guidHash: 'abc',
- feedId: 3
- };
- _this.ItemModel.add(item);
- expect(_this.ItemModel.getById(4)).toBe(item);
- expect(_this.ItemModel.getByGuidHashAndFeedId('abc', 3)).toBe(item);
- _this.ItemModel.removeById(4);
- return expect(_this.ItemModel.getByGuidHashAndFeedId('abc', 3)).toBe(void 0);
- });
- it('should bind the correct isRead() method to the item', function() {
- var item;
- item = {
- id: 3,
- guidHash: 'abc',
- feedId: 6,
- status: 16
- };
- _this.ItemModel.add(item);
- item.setRead();
- return expect(_this.ItemModel.getById(3).isRead()).toBe(true);
- });
- it('should bind the correct set unread method to the item', function() {
- var item;
- item = {
- id: 3,
- guidHash: 'abc',
- feedId: 6,
- status: 16
- };
- _this.ItemModel.add(item);
- item.setUnread();
- return expect(_this.ItemModel.getById(3).isRead()).toBe(false);
- });
- it('should bind the correct set starred method to the item', function() {
- var item;
- item = {
- id: 3,
- guidHash: 'abc',
- feedId: 6,
- status: 16
- };
- _this.ItemModel.add(item);
- item.setStarred();
- return expect(_this.ItemModel.getById(3).isStarred()).toBe(true);
- });
- it('should bind the correct set unstarred method to the item', function() {
- var item;
- item = {
- id: 3,
- guidHash: 'abc',
- feedId: 6,
- status: 16
- };
- _this.ItemModel.add(item);
- item.setUnstarred();
- return expect(_this.ItemModel.getById(3).isStarred()).toBe(false);
- });
- return it('should return the lowest id', function() {
- _this.ItemModel.add({
- id: 2,
- guidHash: 'abc',
- feedId: 2,
- status: 16
- });
- _this.ItemModel.add({
- id: 3,
- guidHash: 'abcd',
- feedId: 2,
- status: 16
- });
- _this.ItemModel.add({
- id: 1,
- guidHash: 'abce',
- feedId: 2,
- status: 16
- });
- _this.ItemModel.add({
- id: 6,
- guidHash: 'abcf',
- feedId: 2,
- status: 16
- });
- return expect(_this.ItemModel.getLowestId()).toBe(1);
- });
- });
-
-}).call(this);