@@ -14,7 +14,7 @@ function testResponse(assertion, response) {
14
14
15
15
// This is done in the main middleware by
16
16
// overwriting res.write/end
17
- res . _body = JSON . stringify ( response ) ; // eslint-disable-line no-underscore-dangle
17
+ res . _body = response ; // eslint-disable-line no-underscore-dangle
18
18
19
19
res . json ( response ) ;
20
20
} ) ;
@@ -36,7 +36,7 @@ describe('processResponse()', () => {
36
36
) ;
37
37
return done ( ) ;
38
38
} ,
39
- { password : '123456' , apiKey : 'abcdef' , another : 'Hello world' } ,
39
+ JSON . stringify ( { password : '123456' , apiKey : 'abcdef' , another : 'Hello world' } ) ,
40
40
) ;
41
41
} ) ;
42
42
@@ -49,7 +49,21 @@ describe('processResponse()', () => {
49
49
) ;
50
50
return done ( ) ;
51
51
} ,
52
- { password : '123456' , apiKey : 'abcdef' , another : 'Hello world' } ,
52
+ JSON . stringify ( { password : '123456' , apiKey : 'abcdef' , another : 'Hello world' } ) ,
53
+ ) ;
54
+ } ) ;
55
+
56
+ it ( 'should not be applied for plain text bodies' , done => {
57
+ const body = 'hello world: dasdsas' ;
58
+ testResponse (
59
+ res => {
60
+ assert . deepEqual (
61
+ processResponse ( res , { blacklist : [ 'password' , 'apiKey' ] } ) . content . text ,
62
+ JSON . stringify ( body ) ,
63
+ ) ;
64
+ return done ( ) ;
65
+ } ,
66
+ body ,
53
67
) ;
54
68
} ) ;
55
69
} ) ;
@@ -96,6 +110,14 @@ describe('processResponse()', () => {
96
110
97
111
it ( '#text' , done => {
98
112
const body = { a : 1 , b : 2 , c : 3 } ;
113
+ testResponse ( res => {
114
+ assert . deepEqual ( processResponse ( res ) . content . text , JSON . stringify ( body ) ) ;
115
+ return done ( ) ;
116
+ } , JSON . stringify ( body ) ) ;
117
+ } ) ;
118
+
119
+ it ( '#text should work with plain text body' , done => {
120
+ const body = 'hello world: dasdsas' ;
99
121
testResponse ( res => {
100
122
assert . deepEqual ( processResponse ( res ) . content . text , JSON . stringify ( body ) ) ;
101
123
return done ( ) ;
0 commit comments