Skip to content

Commit

Permalink
Add test case for #2808
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoluc committed Oct 11, 2022
1 parent 2a08160 commit c9326e3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/jspsych/tests/randomization/randomziation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,23 @@ afterEach(() => {
});

describe("shuffle", () => {
test("should produce fixed order with mock RNG", () => {
beforeEach(() => {
jest.spyOn(Math, "random").mockReturnValue(0.5);
});

it("should produce fixed order with mock RNG", () => {
const arr = [1, 2, 3, 4, 5, 6];
expect(shuffle(arr)).toEqual([1, 6, 2, 5, 3, 4]);
});

it("should not modify the original array and return a new array instance", () => {
const array = [1, 2, 3];
const shuffledArray = shuffle(array);

expect(array).toEqual([1, 2, 3]);
expect(shuffledArray).not.toBe(array);
expect(shuffledArray).toEqual([1, 3, 2]);
});
});

describe("shuffleAlternateGroups", () => {
Expand Down

0 comments on commit c9326e3

Please sign in to comment.