summaryrefslogtreecommitdiffstats
path: root/js/tests
diff options
context:
space:
mode:
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/controller/ContentControllerSpec.js22
-rw-r--r--js/tests/unit/controller/NavigationControllerSpec.js15
-rw-r--r--js/tests/unit/service/ItemResourceSpec.js29
3 files changed, 65 insertions, 1 deletions
diff --git a/js/tests/unit/controller/ContentControllerSpec.js b/js/tests/unit/controller/ContentControllerSpec.js
index e413df672..dbb88bcbb 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');
}));
@@ -557,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);
+ }));
+
});
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');
+ }));
+
});
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([