1 |
|
2 |
|
3 |
|
4 | getRedirectSettings = require '../libs/return-url'
|
5 |
|
6 | describe 'Lib', ->
|
7 |
|
8 | describe '#getRedirectSettings()', ->
|
9 |
|
10 | it 'should exist as a public function', (done) ->
|
11 |
|
12 | getRedirectSettings.bind(null).should.be.a.Function
|
13 | done()
|
14 |
|
15 | it 'should throw an error if options was not passed as parameter', (done) ->
|
16 |
|
17 | getRedirectSettings.bind(null).should.throw '"options" parameter is required'
|
18 | done()
|
19 |
|
20 | it 'should replace returnUrl with previousUrl if req.url is /admin/logout', (done) ->
|
21 |
|
22 | returnUrl = '/admin/logout?previousUrl=/admin/checkout'
|
23 | options =
|
24 | useReturnUrl: true
|
25 | redirectUrl: '/admin/login?ReturnUrl='
|
26 | logoutUrl: '/admin/logout'
|
27 |
|
28 | expectedReturnUrl = '/admin/checkout'
|
29 | expectedRedirectUrl = '/admin/login?ReturnUrl=/admin/checkout'
|
30 |
|
31 | redirectSettings = getRedirectSettings options, returnUrl
|
32 |
|
33 | redirectSettings.returnUrl.should.be.equal expectedReturnUrl
|
34 | redirectSettings.redirectUrl.should.be.equal expectedRedirectUrl
|
35 | done()
|
36 |
|
37 | it 'should return an object containing return url and redirect url', (done) ->
|
38 |
|
39 | returnUrl = '/admin/checkout'
|
40 | options =
|
41 | useReturnUrl: true
|
42 | redirectUrl: '/admin/login?ReturnUrl='
|
43 | logoutUrl: '/admin/logout'
|
44 |
|
45 | expectedReturnUrl = '/admin/checkout'
|
46 | expectedRedirectUrl = '/admin/login?ReturnUrl=/admin/checkout'
|
47 |
|
48 | redirectSettings = getRedirectSettings options, returnUrl
|
49 |
|
50 | redirectSettings.returnUrl.should.be.equal expectedReturnUrl
|
51 | redirectSettings.redirectUrl.should.be.equal expectedRedirectUrl
|
52 | done() |
\ | No newline at end of file |