Skip to content

Commit

Permalink
ci(test): add unit test for utils.rand
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaodong2008 committed Apr 17, 2024
1 parent 84e9409 commit 94cd7b8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/unit/utils/rand.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { expect, test } from "vitest";
import { rand } from "@/main";

test("Random number", () => {
const num = rand(1, 10);
expect(num).toBeGreaterThanOrEqual(1);

Check failure on line 6 in test/unit/utils/rand.test.ts

View workflow job for this annotation

GitHub Actions / unit-test

test/unit/utils/rand.test.ts > Random number

AssertionError: expected NaN to be greater than or equal to 1 ❯ test/unit/utils/rand.test.ts:6:15
expect(num).toBeLessThanOrEqual(10);
});

test("Random number with decimal", () => {
const num = rand(1, 10, 1);
expect(num).toBeGreaterThanOrEqual(1);
expect(num).toBeLessThanOrEqual(10);
});

0 comments on commit 94cd7b8

Please sign in to comment.