File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ function TestAgent(app, options) {
2929 this . _ca = options . ca ;
3030 this . _key = options . key ;
3131 this . _cert = options . cert ;
32+ this . _prefix = options . prefix ;
3233 }
3334 Agent . call ( this ) ;
3435 this . app = app ;
@@ -43,7 +44,8 @@ TestAgent.prototype.__proto__ = Agent.prototype;
4344// override HTTP verb methods
4445methods . forEach ( function ( method ) {
4546 TestAgent . prototype [ method ] = function ( url , fn ) { // eslint-disable-line no-unused-vars
46- var req = new Test ( this . app , method . toUpperCase ( ) , url ) ;
47+ // TODO: support prefix on actual urls
48+ var req = new Test ( this . app , method . toUpperCase ( ) , ( this . _prefix || '' ) + url ) ;
4749 req . ca ( this . _ca ) ;
4850 req . cert ( this . _cert ) ;
4951 req . key ( this . _key ) ;
Original file line number Diff line number Diff line change @@ -815,6 +815,17 @@ describe('request.agent(app)', function() {
815815 } ) ;
816816} ) ;
817817
818+ describe ( 'request.agent(app, {prefix})' , function ( ) {
819+ it ( 'should apply prefix' , function ( done ) {
820+ var app = express ( ) ;
821+ var agent = request . agent ( app , { prefix : '/api' } ) ;
822+
823+ agent
824+ . get ( '/dummy' )
825+ . expect ( 404 , 'Cannot GET /api/dummy\n' , done ) ;
826+ } ) ;
827+ } ) ;
828+
818829describe ( '.<http verb> works as expected' , function ( ) {
819830 it ( '.delete should work' , function ( done ) {
820831 var app = express ( ) ;
You can’t perform that action at this time.
0 commit comments