File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const common = require ( '../common' ) ;
3
+ const startCLI = require ( '../common/debugger' ) ;
4
+
5
+ common . skipIfInspectorDisabled ( ) ;
6
+
7
+ const assert = require ( 'assert' ) ;
8
+ const http = require ( 'http' ) ;
9
+
10
+ const host = '127.0.0.1' ;
11
+
12
+ const testWhenBadRequest = ( ) => {
13
+ const server = http . createServer ( ( req , res ) => {
14
+ res . statusCode = 400 ;
15
+ res . end ( 'Bad Request' ) ;
16
+ } ) ;
17
+ server . listen ( 0 , async ( ) => {
18
+ try {
19
+ const port = server . address ( ) . port ;
20
+ const cli = startCLI ( [ `${ host } :${ port } ` ] ) ;
21
+ const code = await cli . quit ( ) ;
22
+ assert . strictEqual ( code , 1 ) ;
23
+ } finally {
24
+ server . close ( ) ;
25
+ }
26
+ } ) ;
27
+ } ;
28
+
29
+ const testInvalidJson = ( ) => {
30
+ const server = http . createServer ( ( req , res ) => {
31
+ res . statusCode = 200 ;
32
+ res . end ( 'ok' ) ;
33
+ } ) ;
34
+ server . listen ( 0 , host , async ( ) => {
35
+ try {
36
+ const port = server . address ( ) . port ;
37
+ const cli = startCLI ( [ `${ host } :${ port } ` ] ) ;
38
+ const code = await cli . quit ( ) ;
39
+ assert . strictEqual ( code , 1 ) ;
40
+ } finally {
41
+ server . close ( ) ;
42
+ }
43
+ } ) ;
44
+ } ;
45
+
46
+ testWhenBadRequest ( ) ;
47
+ testInvalidJson ( ) ;
You can’t perform that action at this time.
0 commit comments