Skip to content

Commit

Permalink
add test case for #2912
Browse files Browse the repository at this point in the history
  • Loading branch information
jodeleeuw committed May 17, 2023
1 parent 465527a commit b6d4b18
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions packages/jspsych/tests/core/simulation-mode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,4 +482,50 @@ describe("data simulation mode", () => {
expect(data[1].rt).toBe(200);
expect(data[1].response).toBe("a");
});

test("Simulation mode set via string should work, #2912", async () => {
const simulation_options = {
default: {
simulate: false,
},
long_response: {
simulate: true,
},
};

const timeline = [
{
type: htmlKeyboardResponse,
stimulus: "foo",
},
{
type: htmlKeyboardResponse,
stimulus: "bar",
trial_duration: 1000,
simulation_options: "long_response",
},
];

const { expectRunning, expectFinished, getData, getHTML } = await simulateTimeline(
timeline,
"visual",
simulation_options
);

await expectRunning();

expect(getHTML()).toContain("foo");

jest.runAllTimers();

expect(getHTML()).toContain("foo");

pressKey("a");

expect(getHTML()).toContain("bar");

jest.runAllTimers();

await expectFinished();
});
});

0 comments on commit b6d4b18

Please sign in to comment.