Skip to content

Commit

Permalink
test: refactor to await
Browse files Browse the repository at this point in the history
Changes the promises to async/await in
test/parallel/test-debugger-invalid-json.
  • Loading branch information
anjanakvellore committed Sep 16, 2022
1 parent 0928897 commit 780fac5
Showing 1 changed file with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';
const common = require('../common');
const startCLI = require('../common/debugger');
import { skipIfInspectorDisabled, mustCall } from '../common/index.mjs';

common.skipIfInspectorDisabled();
skipIfInspectorDisabled();

const assert = require('assert');
const http = require('http');
import startCLI from '../common/debugger.js';

import assert from 'assert';
import http from 'http';

const host = '127.0.0.1';

Expand All @@ -14,14 +14,16 @@ const host = '127.0.0.1';
res.statusCode = 400;
res.end('Bad Request');
});
server.listen(0, common.mustCall(() => {

server.listen(0, mustCall(async () => {
const port = server.address().port;
const cli = startCLI([`${host}:${port}`]);
cli.quit().then(common.mustCall((code) => {
try {
const code = await cli.quit();
assert.strictEqual(code, 1);
})).finally(() => {
} finally {
server.close();
});
}
}));
}

Expand All @@ -30,13 +32,15 @@ const host = '127.0.0.1';
res.statusCode = 200;
res.end('some data that is invalid json');
});
server.listen(0, host, common.mustCall(() => {

server.listen(0, host, mustCall(async () => {
const port = server.address().port;
const cli = startCLI([`${host}:${port}`]);
cli.quit().then(common.mustCall((code) => {
try {
const code = await cli.quit();
assert.strictEqual(code, 1);
})).finally(() => {
} finally {
server.close();
});
}
}));
}

0 comments on commit 780fac5

Please sign in to comment.