@@ -98,12 +98,13 @@ describe("http", () => {
98
98
const filepath = join ( __dirname , "/helpers/line-icon.png" ) ;
99
99
const buffer = readFileSync ( filepath ) ;
100
100
return postBinary (
101
- `${ TEST_URL } /post` ,
101
+ `${ TEST_URL } /post/binary ` ,
102
102
testHeaders ,
103
103
buffer ,
104
104
) . then ( ( res : any ) => {
105
105
equal ( res . method , "POST" ) ;
106
- equal ( res . path , "/post" ) ;
106
+ equal ( res . path , "/post/binary" ) ;
107
+ equal ( res . body , buffer . toString ( "base64" ) ) ;
107
108
equal ( res . headers [ "test-header-key" ] , testHeaders [ "test-header-key" ] ) ;
108
109
equal ( res . headers [ "user-agent" ] , `${ pkg . name } /${ pkg . version } ` ) ;
109
110
equal ( res . headers [ "content-type" ] , "image/png" ) ;
@@ -114,19 +115,25 @@ describe("http", () => {
114
115
const filepath = join ( __dirname , "/helpers/line-icon.png" ) ;
115
116
const buffer = readFileSync ( filepath ) ;
116
117
return postBinary (
117
- `${ TEST_URL } /post` ,
118
+ `${ TEST_URL } /post/binary ` ,
118
119
{ } ,
119
120
buffer ,
120
121
"image/jpeg" ,
121
122
) . then ( ( res : any ) => {
123
+ equal ( res . body , buffer . toString ( "base64" ) ) ;
122
124
equal ( res . headers [ "content-type" ] , "image/jpeg" ) ;
123
125
} ) ;
124
126
} ) ;
125
127
126
128
it ( "postBinary with stream" , ( ) => {
127
129
const filepath = join ( __dirname , "/helpers/line-icon.png" ) ;
128
130
const stream = createReadStream ( filepath ) ;
129
- return postBinary ( `${ TEST_URL } /post` , { } , stream ) . then ( ( res : any ) => {
131
+ return postBinary (
132
+ `${ TEST_URL } /post/binary` ,
133
+ { } ,
134
+ stream ,
135
+ ) . then ( ( res : any ) => {
136
+ equal ( res . body , readFileSync ( filepath ) . toString ( "base64" ) ) ;
130
137
equal ( res . headers [ "content-type" ] , "image/png" ) ;
131
138
} ) ;
132
139
} ) ;
0 commit comments