2013-11-13 17:01:15 +00:00
|
|
|
|
2015-10-11 22:59:51 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-10-12 04:59:30 +00:00
|
|
|
const context = require('../helpers/context');
|
2013-11-13 17:01:15 +00:00
|
|
|
|
|
|
|
describe('ctx.path', function(){
|
|
|
|
it('should return the pathname', function(){
|
2015-10-05 18:23:47 +00:00
|
|
|
const ctx = context();
|
2013-11-13 17:01:15 +00:00
|
|
|
ctx.url = '/login?next=/dashboard';
|
|
|
|
ctx.path.should.equal('/login');
|
2015-10-12 20:36:41 +00:00
|
|
|
});
|
|
|
|
});
|
2013-11-13 17:01:15 +00:00
|
|
|
|
|
|
|
describe('ctx.path=', function(){
|
|
|
|
it('should set the pathname', function(){
|
2015-10-05 18:23:47 +00:00
|
|
|
const ctx = context();
|
2013-11-13 17:01:15 +00:00
|
|
|
ctx.url = '/login?next=/dashboard';
|
|
|
|
|
|
|
|
ctx.path = '/logout';
|
|
|
|
ctx.path.should.equal('/logout');
|
|
|
|
ctx.url.should.equal('/logout?next=/dashboard');
|
2015-10-12 20:36:41 +00:00
|
|
|
});
|
2013-11-14 22:18:05 +00:00
|
|
|
|
|
|
|
it('should change .url but not .originalUrl', function(){
|
2015-10-05 18:23:47 +00:00
|
|
|
const ctx = context({ url: '/login' });
|
2013-11-14 22:18:05 +00:00
|
|
|
ctx.path = '/logout';
|
|
|
|
ctx.url.should.equal('/logout');
|
|
|
|
ctx.originalUrl.should.equal('/login');
|
|
|
|
ctx.request.originalUrl.should.equal('/login');
|
2015-10-12 20:36:41 +00:00
|
|
|
});
|
|
|
|
});
|