Skip to content

Commit dca80cd

Browse files
committed
fixup! test: add test for exception handlings in debugger
1 parent 2b08167 commit dca80cd

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

test/parallel/test-debugger-invalid-json.js

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,34 @@ const http = require('http');
99

1010
const host = '127.0.0.1';
1111

12-
const testWhenBadRequest = () => {
12+
{
1313
const server = http.createServer((req, res) => {
1414
res.statusCode = 400;
1515
res.end('Bad Request');
1616
});
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();
17+
server.listen(0, common.mustCall(() => {
18+
const port = server.address().port;
19+
const cli = startCLI([`${host}:${port}`]);
20+
cli.quit().then(common.mustCall((code) => {
2221
assert.strictEqual(code, 1);
23-
} finally {
22+
})).finally(() => {
2423
server.close();
25-
}
26-
});
27-
};
24+
});
25+
}));
26+
}
2827

29-
const testInvalidJson = () => {
28+
{
3029
const server = http.createServer((req, res) => {
3130
res.statusCode = 200;
32-
res.end('ok');
31+
res.end('some data that is invalid json');
3332
});
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();
33+
server.listen(0, host, common.mustCall(() => {
34+
const port = server.address().port;
35+
const cli = startCLI([`${host}:${port}`]);
36+
cli.quit().then(common.mustCall((code) => {
3937
assert.strictEqual(code, 1);
40-
} finally {
38+
})).finally(() => {
4139
server.close();
42-
}
43-
});
44-
};
45-
46-
testWhenBadRequest();
47-
testInvalidJson();
40+
});
41+
}));
42+
}

0 commit comments

Comments
 (0)