From c0e6ca12e83e27b2ef86a58f9a44c0248e711a75 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sat, 21 Mar 2015 00:50:52 +0100 Subject: implement clientside search code --- js/tests/unit/controller/NavigationControllerSpec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'js/tests') diff --git a/js/tests/unit/controller/NavigationControllerSpec.js b/js/tests/unit/controller/NavigationControllerSpec.js index 22c510c3f..d6b016c9a 100644 --- a/js/tests/unit/controller/NavigationControllerSpec.js +++ b/js/tests/unit/controller/NavigationControllerSpec.js @@ -1038,4 +1038,19 @@ describe('NavigationController', function () { })); + it ('should set location on search', inject(function ($controller) { + var location = { + search: jasmine.createSpy('search') + }; + var ctrl = $controller('NavigationController', { + $location: location + }); + + ctrl.search(''); + expect(location.search).toHaveBeenCalledWith('search', null); + + ctrl.search('ab'); + expect(location.search).toHaveBeenCalledWith('search', 'ab'); + })); + }); -- cgit v1.2.3 From 35550fe42e36868be1a3ac471bea6dc89b8b6200 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sat, 21 Mar 2015 10:09:24 +0100 Subject: fix autopaging in search --- js/tests/unit/controller/ContentControllerSpec.js | 10 +++++++- js/tests/unit/service/ItemResourceSpec.js | 29 +++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'js/tests') diff --git a/js/tests/unit/controller/ContentControllerSpec.js b/js/tests/unit/controller/ContentControllerSpec.js index e413df672..5004c3ec2 100644 --- a/js/tests/unit/controller/ContentControllerSpec.js +++ b/js/tests/unit/controller/ContentControllerSpec.js @@ -322,6 +322,12 @@ describe('ContentController', function () { SettingsResource.set('oldestFirst', true); SettingsResource.set('showAll', false); + var $location = { + search: jasmine.createSpy('search').and.returnValue({ + search: 'some+string' + }) + }; + var $route = { current: { $$route: { @@ -363,6 +369,7 @@ describe('ContentController', function () { ItemResource: ItemResource, SettingsResource: SettingsResource, data: {'items': [{id: 3}, {id: 4}]}, + $location: $location }); expect(ctrl.autoPagingEnabled()).toBe(true); @@ -372,7 +379,8 @@ describe('ContentController', function () { expect(ctrl.autoPagingEnabled()).toBe(false); expect(Loading.isLoading('autopaging')).toBe(false); - expect(ItemResource.autoPage).toHaveBeenCalledWith(3, 2, true, false); + expect(ItemResource.autoPage).toHaveBeenCalledWith(3, 2, true, false, + 'some+string'); })); diff --git a/js/tests/unit/service/ItemResourceSpec.js b/js/tests/unit/service/ItemResourceSpec.js index a3228f7a4..397ba0841 100644 --- a/js/tests/unit/service/ItemResourceSpec.js +++ b/js/tests/unit/service/ItemResourceSpec.js @@ -267,6 +267,35 @@ describe('ItemResource', function () { })); + 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, + unread: true + }, + { + id: 5, + feedId: 3, + unread: true + }, + { + id: 4, + feedId: 4, + unread: true + } + ], 'items'); + + ItemResource.autoPage(3, 4, true, true, 'some string'); + + http.flush(); + })); + it ('should clear all state', inject(function (ItemResource) { ItemResource.receive([ -- cgit v1.2.3 From ee3d2332ec97487893ae5f1f46b599c550b25eb6 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 30 Mar 2015 16:20:05 +0200 Subject: fix #156 --- js/tests/unit/controller/ContentControllerSpec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'js/tests') diff --git a/js/tests/unit/controller/ContentControllerSpec.js b/js/tests/unit/controller/ContentControllerSpec.js index 5004c3ec2..dbb88bcbb 100644 --- a/js/tests/unit/controller/ContentControllerSpec.js +++ b/js/tests/unit/controller/ContentControllerSpec.js @@ -565,4 +565,16 @@ describe('ContentController', function () { expect(ctrl.isShowAll()).toBe(true); })); + + it('should return the correct media type', inject(function ($controller) { + + var ctrl = $controller('ContentController', { + data: {}, + }); + + expect(ctrl.getMediaType('audio/test')).toBe('audio'); + expect(ctrl.getMediaType('video/test')).toBe('video'); + expect(ctrl.getMediaType('vides/test')).toBe(undefined); + })); + }); -- cgit v1.2.3