From e4c347be0b61ede6fa18227f4417455315b58a1c Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Thu, 1 Jan 2026 16:22:17 +0100 Subject: [PATCH] make sure we use test suites --- .../monitor-conditions/test-evaluator.js | 12 +++---- .../monitor-conditions/test-operators.js | 36 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/test/backend-test/monitor-conditions/test-evaluator.js b/test/backend-test/monitor-conditions/test-evaluator.js index edd051abd..f2e967b81 100644 --- a/test/backend-test/monitor-conditions/test-evaluator.js +++ b/test/backend-test/monitor-conditions/test-evaluator.js @@ -1,17 +1,17 @@ -const test = require("node:test"); +const { describe, test } = require("node:test"); const assert = require("node:assert"); const { ConditionExpressionGroup, ConditionExpression, LOGICAL } = require("../../../server/monitor-conditions/expression.js"); const { evaluateExpressionGroup, evaluateExpression } = require("../../../server/monitor-conditions/evaluator.js"); -test("Expression Evaluator", async (t) => { - await t.test("evaluateExpression() returns true when condition matches and false otherwise", async (t) => { +describe("Expression Evaluator", () => { + test("evaluateExpression() returns true when condition matches and false otherwise", () => { const expr = new ConditionExpression("record", "contains", "mx1.example.com"); assert.strictEqual(true, evaluateExpression(expr, { record: "mx1.example.com" })); assert.strictEqual(false, evaluateExpression(expr, { record: "mx2.example.com" })); }); - await t.test("evaluateExpressionGroup() with AND logic requires all conditions to be true", async (t) => { + test("evaluateExpressionGroup() with AND logic requires all conditions to be true", () => { const group = new ConditionExpressionGroup([ new ConditionExpression("record", "contains", "mx1."), new ConditionExpression("record", "contains", "example.com", LOGICAL.AND), @@ -21,7 +21,7 @@ test("Expression Evaluator", async (t) => { assert.strictEqual(false, evaluateExpressionGroup(group, { record: "example.com" })); }); - await t.test("evaluateExpressionGroup() with OR logic requires at least one condition to be true", async (t) => { + test("evaluateExpressionGroup() with OR logic requires at least one condition to be true", () => { const group = new ConditionExpressionGroup([ new ConditionExpression("record", "contains", "example.com"), new ConditionExpression("record", "contains", "example.org", LOGICAL.OR), @@ -31,7 +31,7 @@ test("Expression Evaluator", async (t) => { assert.strictEqual(false, evaluateExpressionGroup(group, { record: "example.net" })); }); - await t.test("evaluateExpressionGroup() evaluates nested groups correctly", async (t) => { + test("evaluateExpressionGroup() evaluates nested groups correctly", () => { const group = new ConditionExpressionGroup([ new ConditionExpression("record", "contains", "mx1."), new ConditionExpressionGroup([ diff --git a/test/backend-test/monitor-conditions/test-operators.js b/test/backend-test/monitor-conditions/test-operators.js index ef10d63a2..6a6739631 100644 --- a/test/backend-test/monitor-conditions/test-operators.js +++ b/test/backend-test/monitor-conditions/test-operators.js @@ -1,98 +1,98 @@ -const test = require("node:test"); +const { describe, test } = require("node:test"); const assert = require("node:assert"); const { operatorMap, OP_CONTAINS, OP_NOT_CONTAINS, OP_LT, OP_GT, OP_LTE, OP_GTE, OP_STR_EQUALS, OP_STR_NOT_EQUALS, OP_NUM_EQUALS, OP_NUM_NOT_EQUALS, OP_STARTS_WITH, OP_ENDS_WITH, OP_NOT_STARTS_WITH, OP_NOT_ENDS_WITH } = require("../../../server/monitor-conditions/operators.js"); -test("Expression Operators", async (t) => { - await t.test("StringEqualsOperator returns true for identical strings and false otherwise", async (t) => { +describe("Expression Operators", () => { + test("StringEqualsOperator returns true for identical strings and false otherwise", () => { const op = operatorMap.get(OP_STR_EQUALS); assert.strictEqual(true, op.test("mx1.example.com", "mx1.example.com")); assert.strictEqual(false, op.test("mx1.example.com", "mx1.example.org")); assert.strictEqual(false, op.test("1", 1)); // strict equality }); - await t.test("StringNotEqualsOperator returns true for different strings and false for identical strings", async (t) => { + test("StringNotEqualsOperator returns true for different strings and false for identical strings", () => { const op = operatorMap.get(OP_STR_NOT_EQUALS); assert.strictEqual(true, op.test("mx1.example.com", "mx1.example.org")); assert.strictEqual(false, op.test("mx1.example.com", "mx1.example.com")); assert.strictEqual(true, op.test(1, "1")); // variable is not typecasted (strict equality) }); - await t.test("ContainsOperator returns true when scalar contains substring", async (t) => { + test("ContainsOperator returns true when scalar contains substring", () => { const op = operatorMap.get(OP_CONTAINS); assert.strictEqual(true, op.test("mx1.example.org", "example.org")); assert.strictEqual(false, op.test("mx1.example.org", "example.com")); }); - await t.test("ContainsOperator returns true when array contains element", async (t) => { + test("ContainsOperator returns true when array contains element", () => { const op = operatorMap.get(OP_CONTAINS); assert.strictEqual(true, op.test([ "example.org" ], "example.org")); assert.strictEqual(false, op.test([ "example.org" ], "example.com")); }); - await t.test("NotContainsOperator returns true when scalar does not contain substring", async (t) => { + test("NotContainsOperator returns true when scalar does not contain substring", () => { const op = operatorMap.get(OP_NOT_CONTAINS); assert.strictEqual(true, op.test("example.org", ".com")); assert.strictEqual(false, op.test("example.org", ".org")); }); - await t.test("NotContainsOperator returns true when array does not contain element", async (t) => { + test("NotContainsOperator returns true when array does not contain element", () => { const op = operatorMap.get(OP_NOT_CONTAINS); assert.strictEqual(true, op.test([ "example.org" ], "example.com")); assert.strictEqual(false, op.test([ "example.org" ], "example.org")); }); - await t.test("StartsWithOperator returns true when string starts with prefix", async (t) => { + test("StartsWithOperator returns true when string starts with prefix", () => { const op = operatorMap.get(OP_STARTS_WITH); assert.strictEqual(true, op.test("mx1.example.com", "mx1")); assert.strictEqual(false, op.test("mx1.example.com", "mx2")); }); - await t.test("NotStartsWithOperator returns true when string does not start with prefix", async (t) => { + test("NotStartsWithOperator returns true when string does not start with prefix", () => { const op = operatorMap.get(OP_NOT_STARTS_WITH); assert.strictEqual(true, op.test("mx1.example.com", "mx2")); assert.strictEqual(false, op.test("mx1.example.com", "mx1")); }); - await t.test("EndsWithOperator returns true when string ends with suffix", async (t) => { + test("EndsWithOperator returns true when string ends with suffix", () => { const op = operatorMap.get(OP_ENDS_WITH); assert.strictEqual(true, op.test("mx1.example.com", "example.com")); assert.strictEqual(false, op.test("mx1.example.com", "example.net")); }); - await t.test("NotEndsWithOperator returns true when string does not end with suffix", async (t) => { + test("NotEndsWithOperator returns true when string does not end with suffix", () => { const op = operatorMap.get(OP_NOT_ENDS_WITH); assert.strictEqual(true, op.test("mx1.example.com", "example.net")); assert.strictEqual(false, op.test("mx1.example.com", "example.com")); }); - await t.test("NumberEqualsOperator returns true for equal numbers with type coercion", async (t) => { + test("NumberEqualsOperator returns true for equal numbers with type coercion", () => { const op = operatorMap.get(OP_NUM_EQUALS); assert.strictEqual(true, op.test(1, 1)); assert.strictEqual(true, op.test(1, "1")); assert.strictEqual(false, op.test(1, "2")); }); - await t.test("NumberNotEqualsOperator returns true for different numbers", async (t) => { + test("NumberNotEqualsOperator returns true for different numbers", () => { const op = operatorMap.get(OP_NUM_NOT_EQUALS); assert.strictEqual(true, op.test(1, "2")); assert.strictEqual(false, op.test(1, "1")); }); - await t.test("LessThanOperator returns true when first number is less than second", async (t) => { + test("LessThanOperator returns true when first number is less than second", () => { const op = operatorMap.get(OP_LT); assert.strictEqual(true, op.test(1, 2)); assert.strictEqual(true, op.test(1, "2")); assert.strictEqual(false, op.test(1, 1)); }); - await t.test("GreaterThanOperator returns true when first number is greater than second", async (t) => { + test("GreaterThanOperator returns true when first number is greater than second", () => { const op = operatorMap.get(OP_GT); assert.strictEqual(true, op.test(2, 1)); assert.strictEqual(true, op.test(2, "1")); assert.strictEqual(false, op.test(1, 1)); }); - await t.test("LessThanOrEqualToOperator returns true when first number is less than or equal to second", async (t) => { + test("LessThanOrEqualToOperator returns true when first number is less than or equal to second", () => { const op = operatorMap.get(OP_LTE); assert.strictEqual(true, op.test(1, 1)); assert.strictEqual(true, op.test(1, 2)); @@ -100,7 +100,7 @@ test("Expression Operators", async (t) => { assert.strictEqual(false, op.test(1, 0)); }); - await t.test("GreaterThanOrEqualToOperator returns true when first number is greater than or equal to second", async (t) => { + test("GreaterThanOrEqualToOperator returns true when first number is greater than or equal to second", () => { const op = operatorMap.get(OP_GTE); assert.strictEqual(true, op.test(1, 1)); assert.strictEqual(true, op.test(2, 1));