Skip to content

Commit c5d662b

Browse files
[autofix.ci] apply automated fixes
1 parent d660507 commit c5d662b

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

test/backend-test/test-util-server.js

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,49 @@ const assert = require("node:assert");
33
const { pingAsync } = require("../../server/util-server");
44

55
describe("Server Utilities: pingAsync", () => {
6-
76
test("should convert IDN domains to Punycode before pinging", async () => {
87
const idnDomain = "münchen.de";
98
const punycodeDomain = "xn--mnchen-3ya.de";
109

11-
await assert.rejects(
12-
pingAsync(idnDomain, false, 1, "", true, 56, 1, 1),
13-
(err) => {
14-
if (err.message.includes("Parameter string not correctly encoded")) {
15-
assert.fail("Ping failed with encoding error: IDN was not converted");
16-
}
17-
assert.ok(err.message.includes(punycodeDomain), `Error message should contain the Punycode domain "${punycodeDomain}". Got: ${err.message}`);
18-
return true;
10+
await assert.rejects(pingAsync(idnDomain, false, 1, "", true, 56, 1, 1), (err) => {
11+
if (err.message.includes("Parameter string not correctly encoded")) {
12+
assert.fail("Ping failed with encoding error: IDN was not converted");
1913
}
20-
);
14+
assert.ok(
15+
err.message.includes(punycodeDomain),
16+
`Error message should contain the Punycode domain "${punycodeDomain}". Got: ${err.message}`
17+
);
18+
return true;
19+
});
2120
});
2221

2322
test("should strip brackets from IPv6 addresses before pinging", async () => {
2423
const ipv6WithBrackets = "[2001:db8::1]";
2524
const ipv6Raw = "2001:db8::1";
2625

27-
await assert.rejects(
28-
pingAsync(ipv6WithBrackets, true, 1, "", true, 56, 1, 1),
29-
(err) => {
30-
assert.strictEqual(err.message.includes(ipv6WithBrackets), false, "Error message should not contain brackets");
31-
assert.ok(err.message.includes(ipv6Raw), `Error message should contain the raw IP "${ipv6Raw}". Got: ${err.message}`);
32-
return true;
33-
}
34-
);
26+
await assert.rejects(pingAsync(ipv6WithBrackets, true, 1, "", true, 56, 1, 1), (err) => {
27+
assert.strictEqual(
28+
err.message.includes(ipv6WithBrackets),
29+
false,
30+
"Error message should not contain brackets"
31+
);
32+
assert.ok(
33+
err.message.includes(ipv6Raw),
34+
`Error message should contain the raw IP "${ipv6Raw}". Got: ${err.message}`
35+
);
36+
return true;
37+
});
3538
});
3639

3740
test("should handle standard ASCII domains correctly", async () => {
3841
const domain = "invalid-domain.test";
39-
await assert.rejects(
40-
pingAsync(domain, false, 1, "", true, 56, 1, 1),
41-
(err) => {
42-
assert.strictEqual(err.message.includes("Parameter string not correctly encoded"), false);
43-
assert.ok(err.message.includes(domain), `Error message should contain the domain "${domain}". Got: ${err.message}`);
44-
return true;
45-
}
46-
);
42+
await assert.rejects(pingAsync(domain, false, 1, "", true, 56, 1, 1), (err) => {
43+
assert.strictEqual(err.message.includes("Parameter string not correctly encoded"), false);
44+
assert.ok(
45+
err.message.includes(domain),
46+
`Error message should contain the domain "${domain}". Got: ${err.message}`
47+
);
48+
return true;
49+
});
4750
});
4851
});

0 commit comments

Comments
 (0)