summaryrefslogtreecommitdiffstats
path: root/js/tests
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-04 21:57:17 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-04 21:57:17 +0200
commitd001da33947a0fa1b65f0e1b5749e9b97bd4b779 (patch)
tree73f6ff957e67dc31092a30d883fe36e421bd6b48 /js/tests
parent76267670f3dcb6793a62a30477db830f482b4495 (diff)
cleaned up feedcontroller
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/controllers/feedcontrollerSpec.coffee125
-rw-r--r--js/tests/services/bl/feedblSpec.coffee28
-rw-r--r--js/tests/services/bl/folderblSpec.coffee12
-rw-r--r--js/tests/services/unreadcountformaterSpec.coffee35
4 files changed, 93 insertions, 107 deletions
diff --git a/js/tests/controllers/feedcontrollerSpec.coffee b/js/tests/controllers/feedcontrollerSpec.coffee
index 293a55f47..755e84440 100644
--- a/js/tests/controllers/feedcontrollerSpec.coffee
+++ b/js/tests/controllers/feedcontrollerSpec.coffee
@@ -23,130 +23,43 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
describe '_FeedController', ->
-
beforeEach module 'News'
+ beforeEach =>
+ angular.module('News').factory 'Persistence', =>
+ @persistence = {}
- beforeEach inject (@_FeedController, @ActiveFeed, @ShowAll, @FeedType,
- @StarredCount, @FeedModel, @FolderModel, @FeedBl) =>
- @scope =
- $on: ->
-
- @persistence =
- getItems: ->
-
- @controller = new @_FeedController(@scope, @FolderModel, @FeedModel,
- @ActiveFeed, @ShowAll, @FeedType,
- @StarredCount, @persistence,
- @FeedBl)
-
-
- xit 'should make folders available', =>
- @FolderModel.getAll = jasmine.createSpy('FolderModel')
- new @_FeedController(@scope, @FolderModel, @FeedModel, @_ActiveFeed)
-
- expect(@FolderModel.getAll).toHaveBeenCalled()
-
-
- xit 'should make feeds availabe', =>
- @FeedModel.getAll = jasmine.createSpy('FeedModel')
- new @_FeedController(@scope, @FolderModel, @FeedModel, @_ActiveFeed)
-
- expect(@FeedModel.getAll).toHaveBeenCalled()
-
-
- xit 'should make feedtype available', =>
- expect(@scope.feedType).toBe(@FeedType)
-
-
- xit 'should check the active feed', =>
- @ActiveFeed.getType = =>
- return @FeedType.Feed
- @ActiveFeed.getId = =>
- return 5
-
- expect(@scope.isFeedActive(@FeedType.Feed, 5)).toBeTruthy()
-
-
- xit 'should provide ShowAll', =>
- expect(@scope.isShowAll()).toBeFalsy()
-
- @ShowAll.setShowAll(true)
- expect(@scope.isShowAll()).toBeTruthy()
-
-
- xit 'should handle show all correctly', =>
- @persistence.userSettingsReadHide = jasmine.createSpy('hide')
- @persistence.userSettingsReadShow = jasmine.createSpy('show')
- @scope.setShowAll(true)
- expect(@ShowAll.getShowAll()).toBeTruthy()
- expect(@persistence.userSettingsReadShow).toHaveBeenCalled()
- expect(@persistence.userSettingsReadHide).not.toHaveBeenCalled()
+ beforeEach inject (@_FeedController, @FolderBl, @FeedBl, $rootScope,
+ @unreadCountFormatter) =>
+ @scope = $rootScope.$new()
+ @controller = new @_FeedController(@scope, @persistence, @FolderBl,
+ @FeedBl, @unreadCountFormatter)
- xit 'should handle hide all correctly', =>
- @persistence.userSettingsReadHide = jasmine.createSpy('hide')
- @persistence.userSettingsReadShow = jasmine.createSpy('show')
- @scope.setShowAll(false)
- expect(@ShowAll.getShowAll()).toBeFalsy()
- expect(@persistence.userSettingsReadShow).not.toHaveBeenCalled()
- expect(@persistence.userSettingsReadHide).toHaveBeenCalled()
+ it 'isAddingFolder should return false in the beginning', =>
+ expect(@scope.isAddingFolder()).toBeFalsy()
- xit 'should get the correct count for starred items', =>
- @StarredCount.setStarredCount(133)
- count = @scope.getUnreadCount(@FeedType.Starred, 0)
-
- expect(count).toBe(133)
-
-
- xit 'should set the count to 999+ if the count is over 999', =>
- @StarredCount.setStarredCount(1000)
- count = @scope.getUnreadCount(@FeedType.Starred, 0)
-
- expect(count).toBe('999+')
-
-
-
-
-
- xit 'should set active feed to new feed if changed', =>
- @ActiveFeed.handle({id: 3, type: 3})
- @scope.loadFeed(4, 3)
-
- expect(@ActiveFeed.getId()).toBe(3)
- expect(@ActiveFeed.getType()).toBe(4)
-
-
- xit 'should return true when calling isShown and there are feeds', =>
- @FeedModel.add({id: 3})
- @ShowAll.setShowAll(true)
- expect(@scope.isShown(3, 4)).toBeTruthy()
-
- @ShowAll.setShowAll(false)
- expect(@scope.isShown(3, 4)).toBeFalsy()
+ it 'isAddingFeed should return false in the beginning', =>
+ expect(@scope.isAddingFeed()).toBeFalsy()
- xit 'should return true if ShowAll is false but unreadcount is not 0', =>
- @ShowAll.setShowAll(false)
- @FeedModel.add({id: 4, unreadCount: 0, urlHash: 'a1'})
- expect(@scope.isShown(@FeedType.Feed, 4)).toBeFalsy()
- @FeedModel.add({id: 4, unreadCount: 12, urlHash: 'a2'})
- expect(@scope.isShown(@FeedType.Feed, 4)).toBeTruthy()
+ it 'should make unreadCountFormatter available', =>
+ expect(@scope.unreadCountFormatter).toBe(@unreadCountFormatter)
- xit 'isAddingFolder should return false in the beginning', =>
- expect(@scope.isAddingFolder()).toBeFalsy()
+ it 'should make FeedBl available', =>
+ expect(@scope.feedBl).toBe(@FeedBl)
- xit 'isAddingFeed should return false in the beginning', =>
- expect(@scope.isAddingFeed()).toBeFalsy()
+ it 'should make FolderBl available', =>
+ expect(@scope.folderBl).toBe(@FolderBl)
- xit 'should not add folders that have no name', =>
+ it 'should not add folders that have no name', =>
@persistence.createFolder = jasmine.createSpy('create')
@scope.addFolder(' ')
diff --git a/js/tests/services/bl/feedblSpec.coffee b/js/tests/services/bl/feedblSpec.coffee
index 2ca742cc7..27b681a32 100644
--- a/js/tests/services/bl/feedblSpec.coffee
+++ b/js/tests/services/bl/feedblSpec.coffee
@@ -152,4 +152,30 @@ describe 'FeedBl', ->
@FeedModel.add({id: 2, unreadCount:134, urlHash: 'a1', folderId: 3})
@FeedBl.move(2, 3)
- expect(@persistence.moveFeed).not.toHaveBeenCalled() \ No newline at end of file
+ expect(@persistence.moveFeed).not.toHaveBeenCalled()
+
+
+ it 'should set the show all setting', =>
+ @persistence.userSettingsReadShow = jasmine.createSpy('Show All')
+ @FeedBl.setShowAll(true)
+
+ expect(@persistence.userSettingsReadShow).toHaveBeenCalled()
+
+
+
+ it 'should set the hide read setting', =>
+ @persistence.userSettingsReadHide = jasmine.createSpy('Hide Read')
+ @FeedBl.setShowAll(false)
+
+ expect(@persistence.userSettingsReadHide).toHaveBeenCalled()
+
+
+ it 'should return all feeds', =>
+ item1 = {id: 2, unreadCount:134, urlHash: 'a1', folderId: 3}
+ item2 = {id: 4, unreadCount:134, urlHash: 'a2', folderId: 3}
+ @FeedModel.add(item1)
+ @FeedModel.add(item2)
+
+ expect(@FeedBl.getAll()).toContain(item1)
+ expect(@FeedBl.getAll()).toContain(item2)
+
diff --git a/js/tests/services/bl/folderblSpec.coffee b/js/tests/services/bl/folderblSpec.coffee
index c7590f51f..5c36cf203 100644
--- a/js/tests/services/bl/folderblSpec.coffee
+++ b/js/tests/services/bl/folderblSpec.coffee
@@ -118,3 +118,15 @@ describe 'FolderBl', ->
@ActiveFeed.handle({type: @FeedType.Folder, id:2})
expect(@FolderBl.isVisible(3)).toBe(true)
+
+
+ it 'should return all folders', =>
+ item1 = {id: 3, open: false}
+ item2 = {id: 4, open: true}
+ @FolderModel.add(item1)
+ @FolderModel.add(item2)
+
+ expect(@FolderBl.getAll()).toContain(item1)
+ expect(@FolderBl.getAll()).toContain(item2)
+
+
diff --git a/js/tests/services/unreadcountformaterSpec.coffee b/js/tests/services/unreadcountformaterSpec.coffee
new file mode 100644
index 000000000..f4dabb8cc
--- /dev/null
+++ b/js/tests/services/unreadcountformaterSpec.coffee
@@ -0,0 +1,35 @@
+###
+
+ownCloud - News
+
+@author Bernhard Posselt
+@copyright 2012 Bernhard Posselt nukeawhale@gmail.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 'unreadCountFormatter', ->
+
+ beforeEach module 'News'
+
+ beforeEach inject (@unreadCountFormatter) =>
+
+ it 'should return the normal count if its below 999', =>
+ expect(@unreadCountFormatter(999)).toBe(999)
+
+
+ it 'should set the count to 999+ if the count is over 999', =>
+ expect(@unreadCountFormatter(1000)).toBe('999+') \ No newline at end of file