File tree 1 file changed +7
-9
lines changed
1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change 20
20
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
22
22
'use strict' ;
23
- require ( '../common' ) ;
23
+ const common = require ( '../common' ) ;
24
24
const assert = require ( 'assert' ) ;
25
25
const http = require ( 'http' ) ;
26
26
27
27
const expected = 'Post Body For Test' ;
28
+ const expectedStatusCode = 200 ;
28
29
29
30
const server = http . Server ( function ( req , res ) {
30
31
let result = '' ;
@@ -34,12 +35,12 @@ const server = http.Server(function(req, res) {
34
35
result += chunk ;
35
36
} ) ;
36
37
37
- req . on ( 'end' , function ( ) {
38
+ req . on ( 'end' , common . mustCall ( ( ) => {
38
39
assert . strictEqual ( result , expected ) ;
39
- res . writeHead ( 200 ) ;
40
+ res . writeHead ( expectedStatusCode ) ;
40
41
res . end ( 'hello world\n' ) ;
41
42
server . close ( ) ;
42
- } ) ;
43
+ } ) ) ;
43
44
44
45
} ) ;
45
46
@@ -49,12 +50,9 @@ server.listen(0, function() {
49
50
path : '/' ,
50
51
method : 'POST'
51
52
} , function ( res ) {
52
- console . log ( res . statusCode ) ;
53
+ assert . strictEqual ( res . statusCode , expectedStatusCode ) ;
53
54
res . resume ( ) ;
54
- } ) . on ( 'error' , function ( e ) {
55
- console . log ( e . message ) ;
56
- process . exit ( 1 ) ;
57
- } ) ;
55
+ } ) . on ( 'error' , common . mustNotCall ( ) ) ;
58
56
59
57
const result = req . end ( expected ) ;
60
58
You can’t perform that action at this time.
0 commit comments