From 761412ebaaf0930499ca26e7acdd0965be5a50ae Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Fri, 12 Sep 2014 03:03:44 +0200 Subject: create folders! --- .../unit/controller/NavigationControllerSpec.js | 10 ++++- js/tests/unit/service/FeedResourceSpec.js | 49 +++++++++++----------- js/tests/unit/service/FolderResourceSpec.js | 2 +- 3 files changed, 34 insertions(+), 27 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/controller/NavigationControllerSpec.js b/js/tests/unit/controller/NavigationControllerSpec.js index 23f1b3522..87b45e94c 100644 --- a/js/tests/unit/controller/NavigationControllerSpec.js +++ b/js/tests/unit/controller/NavigationControllerSpec.js @@ -287,7 +287,15 @@ describe('NavigationController', function () { FolderResource) { expect(controller.folderNameExists('hi')).toBe(false); FolderResource.add({name: 'hi'}); - expect(controller.folderNameExists('hi')).toBe(true); + expect(controller.folderNameExists(' hi ')).toBe(true); + })); + + it('should expose check if a feed url exists', inject(function ( + FeedResource) { + expect(controller.feedUrlExists('hi')).toBe(false); + FeedResource.add({url: 'http://hi'}); + expect(controller.feedUrlExists('hi ')).toBe(true); + expect(controller.feedUrlExists('http://hi')).toBe(true); })); diff --git a/js/tests/unit/service/FeedResourceSpec.js b/js/tests/unit/service/FeedResourceSpec.js index edf8ba46d..0878a4954 100644 --- a/js/tests/unit/service/FeedResourceSpec.js +++ b/js/tests/unit/service/FeedResourceSpec.js @@ -151,68 +151,67 @@ describe('FeedResource', function () { })); - it ('should create a feed', inject(function (FeedResource) { + it ('should create a feed and prepend http if not given', inject(function ( + FeedResource) { http.expectPOST('base/feeds', { parentFolderId: 5, - url: 'hey', + url: 'http://hey', title: 'ABC' }).respond(200, {}); - FeedResource.create('hey', 5, 'abc'); + FeedResource.create(' hey ', 5, ' abc'); http.flush(); - expect(FeedResource.get('hey').folderId).toBe(5); + expect(FeedResource.get('http://hey').folderId).toBe(5); })); - it ('should display a feed error', inject(function (FeedResource) { + it ('should create a feed', inject(function (FeedResource) { http.expectPOST('base/feeds', { parentFolderId: 5, - url: 'hey', + url: 'http://hey', title: 'ABC' - }).respond(400, {message: 'noo'}); + }).respond(200, {}); - FeedResource.create('hey', 5, 'abc'); + FeedResource.create('http://hey', 5, 'abc'); http.flush(); - expect(FeedResource.get('hey').error).toBe('noo'); - expect(FeedResource.get('hey').faviconLink).toBe(''); + expect(FeedResource.get('http://hey').folderId).toBe(5); })); - it ('should create a feed with no folder', inject(function (FeedResource) { + it ('should display a feed error', inject(function (FeedResource) { http.expectPOST('base/feeds', { - parentFolderId: 0, - url: 'hey', + parentFolderId: 5, + url: 'https://hey', title: 'ABC' - }).respond(200, {}); + }).respond(400, {message: 'noo'}); - FeedResource.create('hey', undefined, 'abc'); + FeedResource.create('https://hey', 5, 'abc'); http.flush(); - expect(FeedResource.get('hey').folderId).toBe(0); - expect(FeedResource.get('hey').faviconLink).toBe( - '/base/apps/news/css/loading.gif'); + expect(FeedResource.get('https://hey').error).toBe('noo'); + expect(FeedResource.get('https://hey').faviconLink).toBe(''); })); - - it ('should not create a feed if it exists', inject(function ( - FeedResource) { + it ('should create a feed with no folder', inject(function (FeedResource) { http.expectPOST('base/feeds', { - parentFolderId: 5, - url: 'ye', + parentFolderId: 0, + url: 'http://hey', title: 'ABC' }).respond(200, {}); - FeedResource.create('ye', 5, 'abc'); + FeedResource.create('hey', undefined, 'abc'); http.flush(); - expect(FeedResource.size()).toBe(3); + expect(FeedResource.get('http://hey').folderId).toBe(0); + expect(FeedResource.get('http://hey').faviconLink).toBe( + '/base/apps/news/css/loading.gif'); })); diff --git a/js/tests/unit/service/FolderResourceSpec.js b/js/tests/unit/service/FolderResourceSpec.js index 7c8cd52dd..6d3e73799 100644 --- a/js/tests/unit/service/FolderResourceSpec.js +++ b/js/tests/unit/service/FolderResourceSpec.js @@ -77,7 +77,7 @@ describe('FolderResource', function () { folderName: 'hey' }).respond(200, {}); - FolderResource.create('hey'); + FolderResource.create(' hey '); http.flush(); -- cgit v1.2.3