summaryrefslogtreecommitdiffstats
path: root/js/tests
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2013-12-19 15:15:32 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2013-12-19 15:15:32 +0100
commit6dc8dad23eea121989e0a89a67e92091802857a0 (patch)
tree15d6b5eda5fece8bf691d5ef8662f697b56b7073 /js/tests
parent28d28d8c9eb5ed9f184b572cfd16994c024e4227 (diff)
add persistent option for compact view
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/controllers/itemcontrollerSpec.coffee10
-rw-r--r--js/tests/controllers/settingscontrollerSpec.coffee13
-rw-r--r--js/tests/services/compactSpec.coffee44
-rw-r--r--js/tests/services/persistenceSpec.coffee17
4 files changed, 81 insertions, 3 deletions
diff --git a/js/tests/controllers/itemcontrollerSpec.coffee b/js/tests/controllers/itemcontrollerSpec.coffee
index 27fc82f71..955f9fe16 100644
--- a/js/tests/controllers/itemcontrollerSpec.coffee
+++ b/js/tests/controllers/itemcontrollerSpec.coffee
@@ -40,7 +40,7 @@ describe 'ItemController', ->
beforeEach inject ($controller, @ItemBusinessLayer, @FeedBusinessLayer,
$rootScope, @FeedLoading, @AutoPageLoading, @FeedModel, @ItemModel,
- @ActiveFeed, @FeedType, @NewestItem) =>
+ @ActiveFeed, @FeedType, @NewestItem, @Compact) =>
@ActiveFeed.handle({type: @FeedType.Folder, id: 3})
@scope = $rootScope.$new()
@@ -183,4 +183,10 @@ describe 'ItemController', ->
callback()
@scope.loadNew()
- expect(@scope.refresh).toBe(false) \ No newline at end of file
+ expect(@scope.refresh).toBe(false)
+
+
+ it 'should bind the compact object', =>
+ expect(@scope.isCompactView()).toBe(false)
+ @Compact.handle(true)
+ expect(@scope.isCompactView()).toBe(true) \ No newline at end of file
diff --git a/js/tests/controllers/settingscontrollerSpec.coffee b/js/tests/controllers/settingscontrollerSpec.coffee
index beb404261..bdf1f2bc2 100644
--- a/js/tests/controllers/settingscontrollerSpec.coffee
+++ b/js/tests/controllers/settingscontrollerSpec.coffee
@@ -30,7 +30,7 @@ describe 'SettingsController', ->
$provide.value 'Persistence', @persistence
return
- beforeEach inject ($controller, @ShowAll) =>
+ beforeEach inject ($controller, @ShowAll, @Compact) =>
@scope = {}
@replace =
'$scope': @scope
@@ -38,6 +38,7 @@ describe 'SettingsController', ->
import: jasmine.createSpy('import')
'FeedBusinessLayer':
importArticles: jasmine.createSpy('import')
+ 'Compact': @Compact
@controller = $controller('SettingsController', @replace)
@@ -88,3 +89,13 @@ describe 'SettingsController', ->
expect(@replace.FeedBusinessLayer.importArticles).toHaveBeenCalledWith(
expected, jasmine.any(Function)
)
+
+
+ it 'should set the compact view', =>
+ @persistence.userSettingsSetCompact = jasmine.createSpy('compact')
+
+ @Compact.handle(false)
+ @scope.setCompactView()
+
+ expect(@persistence.userSettingsSetCompact).toHaveBeenCalledWith(true)
+ expect(@scope.isCompactView()).toBe(true) \ No newline at end of file
diff --git a/js/tests/services/compactSpec.coffee b/js/tests/services/compactSpec.coffee
new file mode 100644
index 000000000..34a1db462
--- /dev/null
+++ b/js/tests/services/compactSpec.coffee
@@ -0,0 +1,44 @@
+###
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+License as published by the Free Software Foundation; either
+version 3 of the License, or any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+You should have received a copy of the GNU Affero General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+###
+
+
+describe 'Compact', ->
+
+ beforeEach module 'News'
+
+ beforeEach inject (@Compact) =>
+ @data = true
+
+
+ it 'should be false by default', =>
+ expect(@Compact.isCompact()).toBe(false)
+
+
+ it 'should set the correct compact', =>
+ @Compact.handle(@data)
+ expect(@Compact.isCompact()).toBe(true)
+
+
+ it 'should set the correct compact', =>
+ @data = false
+ @Compact.handle(@data)
+ expect(@Compact.isCompact()).toBe(false) \ No newline at end of file
diff --git a/js/tests/services/persistenceSpec.coffee b/js/tests/services/persistenceSpec.coffee
index 708a68b07..b9250b974 100644
--- a/js/tests/services/persistenceSpec.coffee
+++ b/js/tests/services/persistenceSpec.coffee
@@ -429,3 +429,20 @@ describe 'Persistence', ->
expect(@req.get).toHaveBeenCalledWith('news_usersettings_language',
expected)
+
+
+ it 'should send a get compact view request', =>
+ @Persistence.userSettingsIsCompact()
+
+ expect(@req.get).toHaveBeenCalledWith('news_usersettings_iscompact')
+
+
+ it 'should send a set compact view request', =>
+ @Persistence.userSettingsSetCompact(true)
+
+ expected =
+ data:
+ compact: true
+
+ expect(@req.post).toHaveBeenCalledWith('news_usersettings_setcompact',
+ expected)