Skip to content

Commit c9326e3

Browse files
committed
Add test case for #2808
1 parent 2a08160 commit c9326e3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/jspsych/tests/randomization/randomziation.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,23 @@ afterEach(() => {
1414
});
1515

1616
describe("shuffle", () => {
17-
test("should produce fixed order with mock RNG", () => {
17+
beforeEach(() => {
1818
jest.spyOn(Math, "random").mockReturnValue(0.5);
19+
});
20+
21+
it("should produce fixed order with mock RNG", () => {
1922
const arr = [1, 2, 3, 4, 5, 6];
2023
expect(shuffle(arr)).toEqual([1, 6, 2, 5, 3, 4]);
2124
});
25+
26+
it("should not modify the original array and return a new array instance", () => {
27+
const array = [1, 2, 3];
28+
const shuffledArray = shuffle(array);
29+
30+
expect(array).toEqual([1, 2, 3]);
31+
expect(shuffledArray).not.toBe(array);
32+
expect(shuffledArray).toEqual([1, 3, 2]);
33+
});
2234
});
2335

2436
describe("shuffleAlternateGroups", () => {

0 commit comments

Comments
 (0)