summaryrefslogtreecommitdiffstats
path: root/js-old/tests/unit/service
diff options
context:
space:
mode:
Diffstat (limited to 'js-old/tests/unit/service')
-rw-r--r--js-old/tests/unit/service/FeedResourceSpec.js338
-rw-r--r--js-old/tests/unit/service/FolderResourceSpec.js148
-rw-r--r--js-old/tests/unit/service/ItemResourceSpec.js387
-rw-r--r--js-old/tests/unit/service/LoadingSpec.js26
-rw-r--r--js-old/tests/unit/service/OPMLImporterSpec.js31
-rw-r--r--js-old/tests/unit/service/OPMLParserSpec.js87
-rw-r--r--js-old/tests/unit/service/PublisherSpec.js54
-rw-r--r--js-old/tests/unit/service/ResourceSpec.js140
-rw-r--r--js-old/tests/unit/service/SettingsResourceSpec.js101
9 files changed, 1312 insertions, 0 deletions
diff --git a/js-old/tests/unit/service/FeedResourceSpec.js b/js-old/tests/unit/service/FeedResourceSpec.js
new file mode 100644
index 000000000..b9f3c2e5a
--- /dev/null
+++ b/js-old/tests/unit/service/FeedResourceSpec.js
@@ -0,0 +1,338 @@
+/**
+ * Nextcloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+describe('FeedResource', function () {
+ 'use strict';
+
+ var resource,
+ http;
+
+ beforeEach(module('News', function ($provide) {
+ $provide.value('BASE_URL', 'base');
+ }));
+
+ afterEach(function () {
+ http.verifyNoOutstandingExpectation();
+ http.verifyNoOutstandingRequest();
+ });
+
+
+ beforeEach(inject(function (FeedResource, $httpBackend) {
+ resource = FeedResource;
+ http = $httpBackend;
+ FeedResource.receive([
+ {id: 1, folderId: 3, url: 'ye', unreadCount: 45},
+ {id: 2, folderId: 4, location: 'test', url: 'sye', unreadCount: 25},
+ {id: 3, folderId: 3, title: 'hore', url: '1sye', unreadCount: 0,
+ ordering: 0}
+ ]);
+ }));
+
+ it('should mark all read', inject(function (FeedResource) {
+
+ FeedResource.markRead();
+
+ expect(FeedResource.getUnreadCount()).toBe(0);
+ }));
+
+ it('should mark a feed read', inject(function (FeedResource) {
+
+ FeedResource.markFeedRead(1);
+
+ expect(FeedResource.get('ye').unreadCount).toBe(0);
+ }));
+
+
+ it('should mark an item read', inject(function (FeedResource) {
+
+ FeedResource.markItemOfFeedRead(1);
+
+ expect(FeedResource.get('ye').unreadCount).toBe(44);
+ }));
+
+ it('should mark an item unread', inject(function (FeedResource) {
+
+ FeedResource.markItemOfFeedUnread(1);
+
+ expect(FeedResource.get('ye').unreadCount).toBe(46);
+ }));
+
+
+ it('should get all of folder', inject(function (FeedResource) {
+
+ var folders = FeedResource.getByFolderId(3);
+
+ expect(folders.length).toBe(2);
+ }));
+
+
+
+ it('should cache unreadcount', inject(function (FeedResource) {
+ expect(FeedResource.getUnreadCount()).toBe(70);
+
+ FeedResource.markItemOfFeedRead(3);
+ expect(FeedResource.getUnreadCount()).toBe(69);
+
+ FeedResource.markItemOfFeedUnread(3);
+ expect(FeedResource.getUnreadCount()).toBe(70);
+
+ FeedResource.markFolderRead(3);
+ expect(FeedResource.getUnreadCount()).toBe(25);
+
+ FeedResource.markRead();
+ expect(FeedResource.getUnreadCount()).toBe(0);
+ }));
+
+
+ it('should cache folder unreadcount', inject(function (FeedResource) {
+ expect(FeedResource.getFolderUnreadCount(3)).toBe(45);
+
+ FeedResource.markItemOfFeedRead(3);
+ expect(FeedResource.getFolderUnreadCount(3)).toBe(44);
+
+ FeedResource.markItemOfFeedUnread(3);
+ expect(FeedResource.getFolderUnreadCount(3)).toBe(45);
+
+ FeedResource.markFolderRead(3);
+ expect(FeedResource.getFolderUnreadCount(3)).toBe(0);
+
+ FeedResource.markRead();
+ expect(FeedResource.getFolderUnreadCount(4)).toBe(0);
+ }));
+
+
+ it('should cache unreadcount', inject(function (FeedResource) {
+ FeedResource.markItemsOfFeedsRead([1, 2]);
+ expect(FeedResource.getUnreadCount()).toBe(68);
+ }));
+
+
+
+ it ('should reversibly delete a feed', inject(function (FeedResource) {
+ http.expectDELETE('base/feeds/2').respond(200, {});
+
+ FeedResource.reversiblyDelete(2);
+
+ http.flush();
+
+ expect(FeedResource.getById(2).deleted).toBe(true);
+ expect(FeedResource.getByLocation('test').deleted).toBe(true);
+ expect(FeedResource.getUnreadCount()).toBe(70);
+ }));
+
+
+ it ('should rename a feed', inject(function (FeedResource) {
+ http.expectPATCH('base/feeds/3', {
+ title: 'heho'
+ }).respond(200, {});
+
+ FeedResource.patch(3, {title: 'heho'});
+
+ http.flush();
+ }));
+
+
+ it ('should move a feed', inject(function (FeedResource) {
+ http.expectPATCH('base/feeds/2', {
+ folderId: 5
+ }).respond(200, {});
+
+ FeedResource.move(2, 5);
+
+ http.flush();
+
+ expect(FeedResource.get('sye').folderId).toBe(5);
+ expect(FeedResource.getFolderUnreadCount(5)).toBe(25);
+ }));
+
+
+ it ('should create a feed and prepend https if not given', inject(function (
+ FeedResource) {
+ http.expectPOST('base/feeds', {
+ parentFolderId: 5,
+ url: 'https://hey',
+ title: 'abc',
+ user: 'john',
+ password: 'doe'
+ }).respond(200, {});
+
+ FeedResource.create(' hey ', 5, ' abc', 'john', 'doe');
+
+ http.flush();
+
+ expect(FeedResource.get('https://hey').folderId).toBe(5);
+ }));
+
+
+ it ('should create a feed', inject(function (FeedResource) {
+ http.expectPOST('base/feeds', {
+ parentFolderId: 5,
+ url: 'http://hey',
+ title: 'abc',
+ user: null,
+ password: null
+ }).respond(200, {});
+
+ FeedResource.create('http://hey', 5, 'abc');
+
+ http.flush();
+
+ expect(FeedResource.get('http://hey').folderId).toBe(5);
+ }));
+
+
+ it ('should display a feed error', inject(function (FeedResource) {
+ http.expectPOST('base/feeds', {
+ parentFolderId: 5,
+ url: 'https://hey',
+ title: 'abc',
+ user: null,
+ password: null
+ }).respond(400, {message: 'noo'});
+
+ FeedResource.create('https://hey', 5, 'abc');
+
+ http.flush();
+
+ expect(FeedResource.get('https://hey').error).toBe('noo');
+ expect(FeedResource.get('https://hey').faviconLink).toBe('');
+ }));
+
+
+ it ('should create a feed with no folder', inject(function (FeedResource) {
+ http.expectPOST('base/feeds', {
+ parentFolderId: 0,
+ url: 'https://hey',
+ user: null,
+ password: null
+ }).respond(200, {});
+
+ FeedResource.create('hey', undefined);
+
+ expect(FeedResource.get('https://hey').title).toBe('https://hey');
+ http.flush();
+
+ expect(FeedResource.get('https://hey').folderId).toBe(0);
+ }));
+
+
+ it ('should undo a delete feed', inject(function (FeedResource) {
+ http.expectDELETE('base/feeds/2').respond(200, {});
+
+ FeedResource.reversiblyDelete(2);
+
+ http.flush();
+
+
+ http.expectPOST('base/feeds/2/restore').respond(200, {});
+
+ FeedResource.undoDelete(2);
+
+ http.flush();
+
+ expect(FeedResource.get('sye').id).toBe(2);
+ expect(FeedResource.get('sye').deleted).toBe(false);
+ expect(FeedResource.getUnreadCount()).toBe(70);
+ }));
+
+
+ it ('should delete a feed', inject(function (FeedResource) {
+ var feed = FeedResource.get('sye');
+ var deletedFeed = FeedResource.delete('sye');
+
+ expect(deletedFeed).toBe(feed);
+ expect(FeedResource.get('sye')).toBe(undefined);
+ expect(FeedResource.size()).toBe(2);
+ }));
+
+
+ it ('should delete feeds of a folder', inject(function (FeedResource) {
+ FeedResource.deleteFolder(3);
+
+ expect(FeedResource.get('ye')).toBe(undefined);
+ expect(FeedResource.get('1sye')).toBe(undefined);
+ expect(FeedResource.getUnreadCount()).toBe(25);
+ expect(FeedResource.size()).toBe(1);
+ }));
+
+
+ it ('should reversibly delete a folder', inject(function (FeedResource) {
+ http.expectDELETE('base/feeds/1').respond(200, {});
+ http.expectDELETE('base/feeds/3').respond(200, {});
+
+ FeedResource.reversiblyDeleteFolder(3);
+
+ http.flush();
+
+ expect(FeedResource.getById(1).deleted).toBe(undefined);
+ expect(FeedResource.getById(3).deleted).toBe(undefined);
+ expect(FeedResource.getUnreadCount()).toBe(70);
+ }));
+
+
+ it ('should reversibly undelete a folder', inject(function (FeedResource) {
+ http.expectDELETE('base/feeds/1').respond(200, {});
+ http.expectDELETE('base/feeds/3').respond(200, {});
+
+ FeedResource.reversiblyDeleteFolder(3);
+
+ http.flush();
+
+ http.expectPOST('base/feeds/1/restore').respond(200, {});
+ http.expectPOST('base/feeds/3/restore').respond(200, {});
+
+ FeedResource.undoDeleteFolder(3);
+
+ http.flush();
+
+ expect(FeedResource.getById(1).deleted).toBe(false);
+ expect(FeedResource.getById(3).deleted).toBe(false);
+ expect(FeedResource.getUnreadCount()).toBe(70);
+ }));
+
+
+ it ('should set the feed ordering', inject(function (FeedResource) {
+ http.expectPATCH('base/feeds/3', {
+ ordering: 2
+ }).respond(200, {});
+
+ FeedResource.patch(3, {ordering: 2});
+
+ http.flush();
+
+ expect(FeedResource.getById(3).ordering).toBe(2);
+ }));
+
+
+ it ('should set the feed pinning', inject(function (FeedResource) {
+ http.expectPATCH('base/feeds/3', {
+ pinned: true
+ }).respond(200, {});
+
+ FeedResource.patch(3, {pinned: true});
+
+ http.flush();
+
+ expect(FeedResource.getById(3).pinned).toBe(true);
+ }));
+
+
+ it ('should toggle full text', inject(function (FeedResource) {
+ http.expectPATCH('base/feeds/3', {
+ fullTextEnabled: true
+ }).respond(200, {});
+
+ FeedResource.getById(3).fullTextEnabled = false;
+ FeedResource.toggleFullText(3);
+
+ expect(FeedResource.getById(3).fullTextEnabled).toBe(true);
+ http.flush();
+ }));
+
+});
diff --git a/js-old/tests/unit/service/FolderResourceSpec.js b/js-old/tests/unit/service/FolderResourceSpec.js
new file mode 100644
index 000000000..f38fef7cf
--- /dev/null
+++ b/js-old/tests/unit/service/FolderResourceSpec.js
@@ -0,0 +1,148 @@
+/**
+ * Nextcloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+describe('FolderResource', function () {
+ 'use strict';
+
+ var resource,
+ http;
+
+ beforeEach(module('News', function ($provide) {
+ $provide.value('BASE_URL', 'base');
+ }));
+
+ afterEach(function () {
+ http.verifyNoOutstandingExpectation();
+ http.verifyNoOutstandingRequest();
+ });
+
+
+ beforeEach(inject(function (FolderResource, $httpBackend) {
+ resource = FolderResource;
+ http = $httpBackend;
+ FolderResource.receive([
+ {id: 1, name: 'ye'},
+ {id: 2, name: 'SYE'},
+ {id: 3, name: 'hore', opened: true}
+ ]);
+ }));
+
+
+ it ('should delete a folder', inject(function (FolderResource) {
+ FolderResource.delete('ye');
+ expect(FolderResource.size()).toBe(2);
+ expect(FolderResource.get('ye')).toBe(undefined);
+ }));
+
+
+ it ('should rename a folder', inject(function (FolderResource) {
+ http.expectPOST('base/folders/1/rename', {
+ folderName: 'heho'
+ }).respond(200, {});
+
+ FolderResource.rename('ye', 'heho');
+
+ http.flush();
+
+ expect(FolderResource.get('heho').id).toBe(1);
+ }));
+
+
+ it ('should handle a folderrename error', inject(function (FolderResource) {
+ http.expectPOST('base/folders/1/rename', {
+ folderName: 'heho'
+ }).respond(400, {});
+
+ FolderResource.rename('ye', 'heho');
+
+ http.flush();
+
+ expect(FolderResource.get('ye').id).toBe(1);
+ }));
+
+
+ it ('should open a folder', inject(function (FolderResource) {
+ http.expectPOST('base/folders/3/open', {
+ folderId: 3,
+ open: false,
+ }).respond(200, {});
+
+ FolderResource.toggleOpen('hore');
+
+ http.flush();
+
+ expect(FolderResource.get('hore').opened).toBe(false);
+ }));
+
+
+ it ('should create a folder', inject(function (FolderResource) {
+ http.expectPOST('base/folders', {
+ folderName: 'hey'
+ }).respond(200, {});
+
+ FolderResource.create(' hey ');
+
+ http.flush();
+
+ expect(FolderResource.size()).toBe(4);
+ }));
+
+
+ it ('should set a folder error message', inject(function (FolderResource) {
+ http.expectPOST('base/folders', {
+ folderName: 'hey'
+ }).respond(400, {message: 'carramba'});
+
+ FolderResource.create('hey');
+
+ http.flush();
+
+ expect(FolderResource.get('hey').error).toBe('carramba');
+ }));
+
+
+ it ('should reversibly delete a folder', inject(function (FolderResource) {
+ http.expectDELETE('base/folders/1').respond(200, {});
+
+ FolderResource.reversiblyDelete('ye');
+
+ http.flush();
+
+ expect(FolderResource.get('ye').deleted).toBe(true);
+ }));
+
+
+ it ('should undo a delete folder', inject(function (FolderResource) {
+ http.expectDELETE('base/folders/1').respond(200, {});
+
+ FolderResource.reversiblyDelete('ye');
+
+ http.flush();
+
+ http.expectPOST('base/folders/1/restore').respond(200, {});
+
+ FolderResource.undoDelete('ye');
+
+ http.flush();
+
+ expect(FolderResource.get('ye').deleted).toBe(false);
+ }));
+
+
+ it ('should get a folder by id', inject(function (FolderResource) {
+ expect(FolderResource.getById(1).name).toBe('ye');
+ }));
+
+
+ it ('should delete a folder and its id cache', inject(
+ function (FolderResource) {
+ FolderResource.delete('ye');
+ expect(FolderResource.getById(1)).toBe(undefined);
+ }));
+});
diff --git a/js-old/tests/unit/service/ItemResourceSpec.js b/js-old/tests/unit/service/ItemResourceSpec.js
new file mode 100644
index 000000000..ea573cfbe
--- /dev/null
+++ b/js-old/tests/unit/service/ItemResourceSpec.js
@@ -0,0 +1,387 @@
+/**
+ * Nextcloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+describe('ItemResource', function () {
+ 'use strict';
+
+ var http;
+
+ beforeEach(module('News', function ($provide) {
+ $provide.value('BASE_URL', 'base');
+ $provide.constant('ITEM_BATCH_SIZE', 5);
+ }));
+
+ beforeEach(inject(function ($httpBackend) {
+ http = $httpBackend;
+ }));
+
+ afterEach(function () {
+ http.verifyNoOutstandingExpectation();
+ http.verifyNoOutstandingRequest();
+ });
+
+
+ it('should receive the newestItemId', inject(function (ItemResource) {
+ ItemResource.receive(3, 'newestItemId');
+
+ expect(ItemResource.getNewestItemId()).toBe(3);
+ }));
+
+ it('should filter out item duplicates', inject(function (ItemResource) {
+ ItemResource.receive([{
+ id: 3,
+ fingerprint: 'a'
+ }, {
+ id: 4,
+ fingerprint: 'a'
+ }, {
+ id: 2,
+ fingerprint: 'b'
+ }], 'items');
+ expect(ItemResource.get(3).fingerprint).toBe('a');
+ expect(ItemResource.get(2).fingerprint).toBe('b');
+ expect(ItemResource.get(4)).toBe(undefined);
+ expect(ItemResource.highestId).toBe(4);
+ expect(ItemResource.lowestId).toBe(2);
+ }));
+
+
+ it('should receive the newestItemId', inject(function (ItemResource) {
+ ItemResource.receive(2, 'starred');
+
+ expect(ItemResource.getStarredCount()).toBe(2);
+ }));
+
+
+ it('should mark item as read', inject(function (ItemResource) {
+ http.expectPOST('base/items/3/read', {isRead: true}).respond(200, {});
+
+ ItemResource.receive([
+ {
+ id: 3,
+ feedId: 4,
+ unread: true,
+ fingerprint: 'a'
+ },
+ {
+ id: 4,
+ feedId: 3,
+ unread: true,
+ fingerprint: 'b'
+ }
+ ], 'items');
+
+ ItemResource.markItemRead(3);
+
+ http.flush();
+
+ expect(ItemResource.get(3).unread).toBe(false);
+ }));
+
+
+ it('should mark multiple item as read', inject(function (ItemResource) {
+ http.expectPOST('base/items/read/multiple', {
+ itemIds: [3, 4]
+ }).respond(200, {});
+
+ ItemResource.receive([
+ {
+ id: 3,
+ feedId: 4,
+ unread: true,
+ fingerprint: 'a'
+ },
+ {
+ id: 4,
+ feedId: 3,
+ unread: true,
+ fingerprint: 'b'
+ }
+ ], 'items');
+
+ ItemResource.markItemsRead([3, 4]);
+
+ http.flush();
+
+ expect(ItemResource.get(3).unread).toBe(false);
+ expect(ItemResource.get(4).unread).toBe(false);
+ }));
+
+
+ it('should star item', inject(function (ItemResource) {
+ http.expectPOST('base/items/4/a/star', {isStarred: true})
+ .respond(200, {});
+
+ ItemResource.receive([
+ {
+ id: 3,
+ feedId: 4,
+ fingerprint: 'a',
+ starred: false,
+ guidHash: 'a'
+ },
+ {
+ id: 4,
+ feedId: 3,
+ fingerprint: 'b',
+ starred: false
+ }
+ ], 'items');
+
+ ItemResource.star(3);
+
+ http.flush();
+
+ expect(ItemResource.get(3).starred).toBe(true);
+ expect(ItemResource.getStarredCount()).toBe(1);
+ }));
+
+
+ it('should mark feed as read', inject(function (ItemResource) {
+ http.expectPOST('base/feeds/4/read', {
+ highestItemId: 5
+ }).respond(200, {});
+
+ ItemResource.receive([
+ {
+ id: 3,
+ feedId: 4,
+ fingerprint: 'a',
+ unread: true
+ },
+ {
+ id: 4,
+ feedId: 3,
+ fingerprint: 'b',
+ unread: true
+ },
+ {
+ id: 5,
+ feedId: 4,
+ fingerprint: 'c',
+ unread: true
+ }
+ ], 'items');
+ ItemResource.receive(5, 'newestItemId');
+
+ ItemResource.markFeedRead(4);
+
+ http.flush();
+
+ expect(ItemResource.get(3).unread).toBe(false);
+ expect(ItemResource.get(5).unread).toBe(false);
+ }));
+
+
+ it('should mark all as read', inject(function (ItemResource) {
+ http.expectPOST('base/items/read', {
+ highestItemId: 5
+ }).respond(200, {});
+
+ ItemResource.receive([
+ {
+ id: 3,
+ feedId: 4,
+ fingerprint: 'a',
+ unread: true
+ },
+ {
+ id: 5,
+ feedId: 3,
+ fingerprint: 'b',
+ unread: true
+ },
+ {
+ id: 4,
+ feedId: 4,
+ fingerprint: 'c',
+ unread: true
+ }
+ ], 'items');
+ ItemResource.receive(5, 'newestItemId');
+
+ ItemResource.markRead();
+
+ http.flush();
+
+ expect(ItemResource.get(3).unread).toBe(false);
+ expect(ItemResource.get(4).unread).toBe(false);
+ expect(ItemResource.get(5).unread).toBe(false);
+ }));
+
+
+ it('toggle star', inject(function (ItemResource) {
+ ItemResource.receive([
+ {
+ id: 3,
+ fingerprint: 'a',
+ starred: true
+ },
+ {
+ id: 5,
+ fingerprint: 'b',
+ starred: false
+ }
+ ], 'items');
+
+ ItemResource.star = jasmine.createSpy('star');
+
+ ItemResource.toggleStar(3);
+ expect(ItemResource.star).toHaveBeenCalledWith(3, false);
+
+ ItemResource.toggleStar(5);
+ expect(ItemResource.star).toHaveBeenCalledWith(5, true);
+ }));
+
+
+ it('should auto page newest first', inject(function (ItemResource) {
+ http.expectGET(
+ 'base/items?id=4&limit=5&offset=3&oldestFirst=false&type=3')
+ .respond(200, {});
+
+ ItemResource.receive([
+ {
+ id: 3,
+ feedId: 4,
+ fingerprint: 'a',
+ unread: true
+ },
+ {
+ id: 5,
+ feedId: 3,
+ fingerprint: 'b',
+ unread: true
+ },
+ {
+ id: 4,
+ feedId: 4,
+ fingerprint: 'c',
+ unread: true
+ }
+ ], 'items');
+
+ ItemResource.autoPage(3, 4, false);
+
+ http.flush();
+ }));
+
+
+ it('should auto page oldest first', inject(function (ItemResource) {
+ http.expectGET(
+ 'base/items?id=4&limit=5&offset=5&oldestFirst=true&type=3')
+ .respond(200, {});
+
+ ItemResource.receive([
+ {
+ id: 3,
+ feedId: 4,
+ fingerprint: 'a',
+ unread: true
+ },
+ {
+ id: 5,
+ feedId: 3,
+ fingerprint: 'b',
+ unread: true
+ },
+ {
+ id: 4,
+ feedId: 4,
+ fingerprint: 'c',
+ unread: true
+ }
+ ], 'items');
+
+ ItemResource.autoPage(3, 4, true);
+
+ http.flush();
+ }));
+
+
+ it('should auto page all', inject(function (ItemResource) {
+ http.expectGET(
+ 'base/items?id=4&limit=5&offset=5&oldestFirst=true' +
+ '&search=some+string&showAll=true&type=3')
+ .respond(200, {});
+
+ ItemResource.receive([
+ {
+ id: 3,
+ feedId: 4,
+ fingerprint: 'a',
+ unread: true
+ },
+ {
+ id: 5,
+ feedId: 3,
+ fingerprint: 'b',
+ unread: true
+ },
+ {
+ id: 4,
+ feedId: 4,
+ fingerprint: 'c',
+ unread: true
+ }
+ ], 'items');
+
+ ItemResource.autoPage(3, 4, true, true, 'some string');
+
+ http.flush();
+ }));
+
+
+ it('should clear all state', inject(function (ItemResource) {
+ ItemResource.receive([
+ {
+ id: 3,
+ feedId: 4,
+ fingerprint: 'a',
+ unread: true
+ },
+ {
+ id: 5,
+ feedId: 3,
+ fingerprint: 'b',
+ unread: true
+ },
+ {
+ id: 4,
+ feedId: 4,
+ fingerprint: 'c',
+ unread: true
+ }
+ ], 'items');
+ ItemResource.receive(5, 'newestItemId');
+ ItemResource.receive(4, 'starred');
+
+ ItemResource.clear();
+
+ expect(ItemResource.size()).toBe(0);
+ expect(ItemResource.highestId).toBe(0);
+ expect(ItemResource.lowestId).toBe(0);
+ expect(ItemResource.starredCount).toBe(0);
+ }));
+
+
+ it('should import articles', inject(function (ItemResource) {
+ var json = 'test';
+
+ http.expectPOST('base/feeds/import/articles', {
+ json: json
+ }).respond(200, {});
+
+ ItemResource.importArticles(json);
+
+ http.flush();
+
+ }));
+
+
+}); \ No newline at end of file
diff --git a/js-old/tests/unit/service/LoadingSpec.js b/js-old/tests/unit/service/LoadingSpec.js
new file mode 100644
index 000000000..ecb720730
--- /dev/null
+++ b/js-old/tests/unit/service/LoadingSpec.js
@@ -0,0 +1,26 @@
+/**
+ * Nextcloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+describe('Loading', function () {
+ 'use strict';
+
+ beforeEach(module('News'));
+
+ it('should be not load by default', inject(function (Loading) {
+ expect(Loading.isLoading('global')).toBe(false);
+ expect(Loading.isLoading('content')).toBe(false);
+ expect(Loading.isLoading('autopaging')).toBe(false);
+ }));
+
+ it('should set loading', inject(function (Loading) {
+ Loading.setLoading('global', true);
+ expect(Loading.isLoading('global')).toBe(true);
+ }));
+
+}); \ No newline at end of file
diff --git a/js-old/tests/unit/service/OPMLImporterSpec.js b/js-old/tests/unit/service/OPMLImporterSpec.js
new file mode 100644
index 000000000..ea35a8f95
--- /dev/null
+++ b/js-old/tests/unit/service/OPMLImporterSpec.js
@@ -0,0 +1,31 @@
+/**
+ * Nextcloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+describe('OPMLParser', function () {
+ 'use strict';
+
+ var importer;
+
+ beforeEach(module('News', function ($provide) {
+ $provide.value('BASE_URL', 'base');
+ $provide.value('ITEM_BATCH_SIZE', 3);
+ }));
+
+ beforeEach(inject(function (OPMLImporter) {
+ importer = OPMLImporter;
+ }));
+
+
+ // FIXME: tests missing
+ it ('should parse the correct amount of feeds and folders', function () {
+
+ });
+
+
+});
diff --git a/js-old/tests/unit/service/OPMLParserSpec.js b/js-old/tests/unit/service/OPMLParserSpec.js
new file mode 100644
index 000000000..77aaf3be7
--- /dev/null
+++ b/js-old/tests/unit/service/OPMLParserSpec.js
@@ -0,0 +1,87 @@
+/**
+ * Nextcloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+describe('OPMLParser', function () {
+ 'use strict';
+
+ var result;
+
+ /*jshint multistr: true */
+ /*jshint quotmark: double */
+ var xml = "<?xml version='1.0' ?> \
+ <opml version='1.1'> \
+ <head> \
+ </head> \
+ <body> \
+ <outline htmlUrl='http://www.reddit.com/r/tldr/' text='test_text'/> \
+ <outline text='Design' title='Tesign'> \
+ <outline \
+ htmlUrl='http://worrydream.com/' \
+ text='yo' \
+ title='man' \
+ xmlUrl='http://worrydream.com/feed.xml'/> \
+ <outline text='Mom' title='Me'> \
+ <outline \
+ htmlUrl='http://afaikblog.wordpress.com'/> \
+ <outline \
+ htmlUrl='http://informationarchitects.net' \
+ xmlUrl='http://informationarchitects.net/feed/'/> \
+ </outline> \
+ </outline> \
+ <outline text='Nomadism'> \
+ <outline \
+ htmlUrl='http://a-flat.posterous.com' \
+ title='a-flat' \
+ xmlUrl='http://a-flat.posterous.com/rss.xml'/> \
+ </outline> \
+ \<outline text='Nomadism'&