Skip to content

Commit e608755

Browse files
committed
Update to use the fast check vitest connector
1 parent c62aaa9 commit e608755

File tree

4 files changed

+239
-362
lines changed

4 files changed

+239
-362
lines changed

packages/spectral/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
},
6060
"devDependencies": {
6161
"@biomejs/biome": "1.6.3",
62+
"@fast-check/vitest": "^0.2.4",
6263
"@types/ejs": "3.1.5",
6364
"@types/fs-extra": "11.0.4",
6465
"@types/lodash": "4.17.23",

packages/spectral/src/conditionalLogic/index.test.ts

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { describe, it, expect, test } from "vitest";
2-
3-
import fc from "fast-check";
1+
import { describe, expect } from "vitest";
2+
import { test as it, test, fc } from "@fast-check/vitest";
43
import {
54
ConditionalExpression,
65
BooleanExpression,
@@ -258,12 +257,12 @@ describe("evaluate", () => {
258257
orFalseExpressions,
259258
);
260259

261-
it("should evaluate expressions", () => {
262-
fc.assert(fc.property(trueExpressions, (expression) => evaluate(expression) === true));
260+
it.prop([trueExpressions])("should evaluate expressions", (expression) => {
261+
expect(evaluate(expression)).toBe(true);
263262
});
264263

265-
it("should evaluate false expressions", () => {
266-
fc.assert(fc.property(falseExpressions, (expression) => evaluate(expression) === false));
264+
it.prop([falseExpressions])("should evaluate false expressions", (expression) => {
265+
expect(evaluate(expression)).toBe(false);
267266
});
268267

269268
it("should deep compare equality while attempting to convert types", () => {
@@ -317,34 +316,15 @@ describe("evaluate", () => {
317316
fc.string(),
318317
);
319318

320-
it("should throw error on invalid expression", () => {
321-
fc.assert(
322-
fc.property(invalidExpressions, (expression) => {
323-
try {
324-
evaluate(expression as any);
325-
return false;
326-
} catch {
327-
return true;
328-
}
329-
}),
330-
);
319+
it.prop([invalidExpressions])("should throw error on invalid expression", (expression) => {
320+
expect(() => evaluate(expression as any)).toThrow();
331321
});
332322

333323
it("Expect isEmpty to Validate correctly", () => {
334-
fc.assert(
335-
fc.property(invalidExpressions, () => {
336-
const res = evaluate([UnaryOperator.isEmpty, []]);
337-
expect(res).toBe(true);
338-
}),
339-
);
324+
expect(evaluate([UnaryOperator.isEmpty, []])).toStrictEqual(true);
340325
expect(evaluate([UnaryOperator.isEmpty, ""])).toStrictEqual(true);
341326
expect(evaluate([UnaryOperator.isEmpty, "abc"])).toStrictEqual(false);
342-
fc.assert(
343-
fc.property(invalidExpressions, () => {
344-
const res = evaluate([UnaryOperator.isEmpty, ["Hello ", "World"]]);
345-
expect(res).toBe(false);
346-
}),
347-
);
327+
expect(evaluate([UnaryOperator.isEmpty, ["Hello ", "World"]])).toStrictEqual(false);
348328
});
349329
});
350330

0 commit comments

Comments
 (0)