diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-04-08 22:29:12 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-04-08 22:29:12 +0200 |
commit | a3c78541d7dd72c143e7997a9e5978a7ff6ce10e (patch) | |
tree | b9b0ed0fc3a2d85f993800f4b3519ac361f0e296 /js/tests | |
parent | 460cf8bbd5ea8260c79252d40f35e63b26f4d3a2 (diff) |
use generate url, fix #496
Diffstat (limited to 'js/tests')
-rw-r--r-- | js/tests/services/notimplementederrorSpec.coffee | 2 | ||||
-rw-r--r-- | js/tests/services/requestSpec.coffee | 76 | ||||
-rw-r--r-- | js/tests/services/routerSpec.coffee | 33 |
3 files changed, 17 insertions, 94 deletions
diff --git a/js/tests/services/notimplementederrorSpec.coffee b/js/tests/services/notimplementederrorSpec.coffee index 539f7e0c7..0edc696ae 100644 --- a/js/tests/services/notimplementederrorSpec.coffee +++ b/js/tests/services/notimplementederrorSpec.coffee @@ -1,6 +1,6 @@ ### -ownCloud - News +ownCloud - News @author Bernhard Posselt @copyright 2012 Bernhard Posselt dev@bernhard-posselt.com diff --git a/js/tests/services/requestSpec.coffee b/js/tests/services/requestSpec.coffee index 30c09efc4..c1dfc1327 100644 --- a/js/tests/services/requestSpec.coffee +++ b/js/tests/services/requestSpec.coffee @@ -25,66 +25,22 @@ describe '_Request', -> beforeEach module 'News' beforeEach inject (_Request, _Publisher) => - @router = - generate: (route, values) -> + @utils = + generateUrl: (route, values) -> return 'url' - registerLoadedCallback: (callback) -> - callback() @publisher = new _Publisher() @request = _Request - - it 'should not send requests if not initialized', => - http = jasmine.createSpy('http') - @router.registerLoadedCallback = -> - req = new @request(http, @publisher, @router) - - req.request('route') - - expect(http).not.toHaveBeenCalled() - - - it 'should send requests if initialized', => - success = - success: -> - error: -> - - @router.registerLoadedCallback = (callback) -> - @callback = callback - @router.call = -> - @callback() - - http = jasmine.createSpy('http').andReturn(success) - - config = - route: 'route' - data: - data: - abc: 'test' - - called = - url: 'url' - data: config.data.data - - req = new @request(http, @publisher, @router) - req.request(config.route, config.data) - - @router.call() - - expect(http).toHaveBeenCalledWith(called) - expect(http.callCount).toBe(1) - - - it 'should should call router', => + it 'should should call utils', => success = success: -> error: -> http = jasmine.createSpy('http').andReturn(success) - router = - generate: jasmine.createSpy('router').andReturn('url') - registerLoadedCallback: @router.registerLoadedCallback + utils = + generateUrl: jasmine.createSpy('utils').andReturn('url') + registerLoadedCallback: @utils.registerLoadedCallback config = route: 'route' @@ -92,10 +48,10 @@ describe '_Request', -> routeParams: test: 'test' - req = new @request(http, @publisher, router) + req = new @request(http, @publisher, utils) req.request(config.route, config.data) - expect(router.generate).toHaveBeenCalledWith(config.route, + expect(utils.generateUrl).toHaveBeenCalledWith(config.route, config.data.routeParams) @@ -112,7 +68,7 @@ describe '_Request', -> onSuccess = jasmine.createSpy('onSucces') onFailure = jasmine.createSpy('onFailure') - req = new @request(http, @publisher, @router) + req = new @request(http, @publisher, @utils) data = onSuccess: onSuccess onFailure: onFailure @@ -139,7 +95,7 @@ describe '_Request', -> http = jasmine.createSpy('http').andReturn(success) - req = new @request(http, publisher, @router) + req = new @request(http, publisher, @utils) req.request(null) expect(publisher.publishDataTo).toHaveBeenCalledWith( @@ -154,7 +110,7 @@ describe '_Request', -> error: -> http = jasmine.createSpy('http').andReturn(success) - req = new @request(http, @publisher, @router) + req = new @request(http, @publisher, @utils) defaultConfig = config: @@ -174,7 +130,7 @@ describe '_Request', -> error: -> http = jasmine.createSpy('http').andReturn(success) - req = new @request(http, @publisher, @router) + req = new @request(http, @publisher, @utils) defaultConfig = config: @@ -193,7 +149,7 @@ describe '_Request', -> error: -> http = jasmine.createSpy('http').andReturn(success) - req = new @request(http, @publisher, @router) + req = new @request(http, @publisher, @utils) defaultConfig = config: @@ -214,7 +170,7 @@ describe '_Request', -> error: -> http = jasmine.createSpy('http').andReturn(success) - req = new @request(http, @publisher, @router) + req = new @request(http, @publisher, @utils) data = config: @@ -239,7 +195,7 @@ describe '_Request', -> error: -> http = jasmine.createSpy('http').andReturn(success) - req = new @request(http, @publisher, @router) + req = new @request(http, @publisher, @utils) defaultConfig = config: @@ -259,7 +215,7 @@ describe '_Request', -> error: -> http = jasmine.createSpy('http').andReturn(success) - req = new @request(http, @publisher, @router) + req = new @request(http, @publisher, @utils) defaultConfig = config: diff --git a/js/tests/services/routerSpec.coffee b/js/tests/services/routerSpec.coffee deleted file mode 100644 index 1d9873106..000000000 --- a/js/tests/services/routerSpec.coffee +++ /dev/null @@ -1,33 +0,0 @@ -### - -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 'Router', -> - - beforeEach module 'News' - - beforeEach => - inject (Router) => - @router = Router - - - it 'should have a defined router', => - expect(@router).toBeDefined() |