make the testcases adopt the new backend test styleguide
This commit is contained in:
parent
0953b966db
commit
6b05f6269d
@ -1,29 +1,27 @@
|
||||
const test = require("node:test");
|
||||
const { describe, test } = require("node:test");
|
||||
const assert = require("node:assert");
|
||||
|
||||
const hash = require("../../server/modules/axios-ntlm/lib/hash");
|
||||
|
||||
test("Test createPseudoRandomValue", async (t) => {
|
||||
await t.test("Should create string of different lengths", () => {
|
||||
const lengths = [ 0, 8, 16, 32, 64 ];
|
||||
const hexRegex = /^[0-9a-f]*$/;
|
||||
for (const length of lengths) {
|
||||
describe("createPseudoRandomValue()", () => {
|
||||
test("returns a hexadecimal string with the requested length", () => {
|
||||
for (const length of [0, 8, 16, 32, 64]) {
|
||||
const result = hash.createPseudoRandomValue(length);
|
||||
assert.strictEqual(result.length, length, `Result should have length ${length}`);
|
||||
assert.strictEqual(typeof result, "string", "Result should be a string");
|
||||
assert.ok(hexRegex.test(result), "Result should be a valid hexadecimal string");
|
||||
assert.strictEqual(typeof result, "string");
|
||||
assert.strictEqual(result.length, length);
|
||||
assert.ok(/^[0-9a-f]*$/.test(result));
|
||||
}
|
||||
});
|
||||
|
||||
await t.test("Should create different values on multiple calls", () => {
|
||||
test("returns unique values across multiple calls with the same length", () => {
|
||||
const length = 16;
|
||||
const results = new Set();
|
||||
const iterations = 10;
|
||||
const results = new Set();
|
||||
|
||||
for (let i = 0; i < iterations; i++) {
|
||||
results.add(hash.createPseudoRandomValue(length));
|
||||
}
|
||||
|
||||
assert.strictEqual(results.size, iterations, "All generated values should be unique");
|
||||
assert.strictEqual(results.size, iterations);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user