diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-19 15:54:32 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-19 15:54:32 +0100 |
commit | 676b8dd18742875ae07827792ed88d2b5bb3afb7 (patch) | |
tree | cd4368012b40ff6fa28cefb85e7ab49c729041ca /js/tests | |
parent | 62b6bd485009b5dbb85b50e634ea94aa177d8d42 (diff) |
first stab at recommended sites
Diffstat (limited to 'js/tests')
-rw-r--r-- | js/tests/unit/controller/AppControllerSpec.js | 12 | ||||
-rw-r--r-- | js/tests/unit/controller/ContentControllerSpec.js | 43 | ||||
-rw-r--r-- | js/tests/unit/controller/NavigationControllerSpec.js | 18 |
3 files changed, 70 insertions, 3 deletions
diff --git a/js/tests/unit/controller/AppControllerSpec.js b/js/tests/unit/controller/AppControllerSpec.js index 90dd0aab8..a54b3b034 100644 --- a/js/tests/unit/controller/AppControllerSpec.js +++ b/js/tests/unit/controller/AppControllerSpec.js @@ -10,14 +10,21 @@ describe('AppController', function () { 'use strict'; - var controller; + var controller, + location; beforeEach(module('News', function ($provide) { $provide.value('BASE_URL', 'base'); })); beforeEach(inject(function ($controller) { - controller = $controller('AppController'); + location = { + path: jasmine.createSpy('path') + }; + + controller = $controller('AppController', { + $location: location + }); })); @@ -43,6 +50,7 @@ describe('AppController', function () { FolderResource.add({name: 'test'}); expect(controller.isFirstRun()).toBe(false); + expect(location.path).not.toHaveBeenCalled(); })); });
\ No newline at end of file diff --git a/js/tests/unit/controller/ContentControllerSpec.js b/js/tests/unit/controller/ContentControllerSpec.js index f9a911129..f279906fc 100644 --- a/js/tests/unit/controller/ContentControllerSpec.js +++ b/js/tests/unit/controller/ContentControllerSpec.js @@ -481,4 +481,47 @@ describe('ContentController', function () { })); + + it('should redirect to the explore page if there are no feeds and folders', + inject(function ($controller) { + var location = { + path: jasmine.createSpy('reload') + }; + $controller('ContentController', { + data: {}, + $location: location + }); + + expect(location.path).toHaveBeenCalledWith('/explore'); + })); + + it('should not redirect to the explore page if there are feeds and folders', + inject(function ($controller, FolderResource, FeedResource) { + + FolderResource.add({id: 3, name: 'test'}); + + var location = { + path: jasmine.createSpy('reload') + }; + $controller('ContentController', { + data: {}, + $location: location + }); + + expect(location.path).not.toHaveBeenCalledWith('/explore'); + + FolderResource.clear({id: 3, name: 'test'}); + FeedResource.add({id: 3, url: 'test'}); + + location = { + path: jasmine.createSpy('reload') + }; + $controller('ContentController', { + data: {}, + $location: location + }); + + expect(location.path).not.toHaveBeenCalledWith('/explore'); + })); + }); diff --git a/js/tests/unit/controller/NavigationControllerSpec.js b/js/tests/unit/controller/NavigationControllerSpec.js index 1c23c35f1..72b9fe736 100644 --- a/js/tests/unit/controller/NavigationControllerSpec.js +++ b/js/tests/unit/controller/NavigationControllerSpec.js @@ -225,7 +225,7 @@ describe('NavigationController', function () { })); - it('should check if a starred is active', inject(function (FeedResource, + it('should check if starred is active', inject(function (FeedResource, FEED_TYPE, $controller) { var ctrl = $controller('NavigationController', { FeedResource: FeedResource, @@ -242,6 +242,22 @@ describe('NavigationController', function () { })); + it('should check if explore is active', inject(function (FeedResource, + FEED_TYPE, $controller) { + var ctrl = $controller('NavigationController', { + FeedResource: FeedResource, + $route: { + current: { + $$route: { + type: FEED_TYPE.EXPLORE + } + } + } + }); + + expect(ctrl.isExploreActive()).toBe(true); + })); + it('should check if a feed is active', inject(function (FeedResource, FEED_TYPE, $controller) { |