File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ function TestAgent(app, options) {
29
29
this . _ca = options . ca ;
30
30
this . _key = options . key ;
31
31
this . _cert = options . cert ;
32
+ this . _prefix = options . prefix ;
32
33
}
33
34
Agent . call ( this ) ;
34
35
this . app = app ;
@@ -43,7 +44,8 @@ TestAgent.prototype.__proto__ = Agent.prototype;
43
44
// override HTTP verb methods
44
45
methods . forEach ( function ( method ) {
45
46
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 ) ;
47
49
req . ca ( this . _ca ) ;
48
50
req . cert ( this . _cert ) ;
49
51
req . key ( this . _key ) ;
Original file line number Diff line number Diff line change @@ -815,6 +815,17 @@ describe('request.agent(app)', function() {
815
815
} ) ;
816
816
} ) ;
817
817
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
+
818
829
describe ( '.<http verb> works as expected' , function ( ) {
819
830
it ( '.delete should work' , function ( done ) {
820
831
var app = express ( ) ;
You can’t perform that action at this time.
0 commit comments