jsPsych/packages/jspsych/tests/core/min-rt.test.ts
bjoluc c119650471 Move experiment execution into jsPsych.run()
The `run()` method takes a timeline and returns a promise that is
resolved when the experiment finishes.
Hence, jsPsych can now be initialized without starting an experiment.
This re-enables usage of `jsPsych.timelineVariable()` in timeline
definitions and repairs exclusion checks and extension loading.
2021-07-19 17:10:37 +02:00

50 lines
1.1 KiB
TypeScript

import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response";
import { pressKey, startTimeline } from "../utils";
jest.useFakeTimers("modern");
describe("minimum_valid_rt parameter", () => {
test("has a default value of 0", async () => {
const { getHTML } = await startTimeline([
{
type: htmlKeyboardResponse,
stimulus: "foo",
},
{
type: htmlKeyboardResponse,
stimulus: "bar",
},
]);
expect(getHTML()).toMatch("foo");
pressKey("a");
expect(getHTML()).toMatch("bar");
});
test("correctly prevents fast responses when set", async () => {
const { getHTML } = await startTimeline(
[
{
type: htmlKeyboardResponse,
stimulus: "foo",
},
{
type: htmlKeyboardResponse,
stimulus: "bar",
},
],
{ minimum_valid_rt: 100 }
);
expect(getHTML()).toMatch("foo");
pressKey("a");
expect(getHTML()).toMatch("foo");
jest.advanceTimersByTime(100);
pressKey("a");
expect(getHTML()).toMatch("bar");
});
});