mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 08:38:11 +00:00

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.
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { jest } from "@jest/globals";
|
|
import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response";
|
|
|
|
import { pressKey, startTimeline } from "../utils";
|
|
|
|
jest.useFakeTimers();
|
|
|
|
describe("default iti 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("creates a correct delay when set", async () => {
|
|
const { getHTML } = await startTimeline(
|
|
[
|
|
{
|
|
type: htmlKeyboardResponse,
|
|
stimulus: "foo",
|
|
},
|
|
{
|
|
type: htmlKeyboardResponse,
|
|
stimulus: "bar",
|
|
},
|
|
],
|
|
{ default_iti: 100 }
|
|
);
|
|
|
|
expect(getHTML()).toMatch("foo");
|
|
expect(getHTML()).not.toMatch("bar");
|
|
pressKey("a");
|
|
jest.advanceTimersByTime(100);
|
|
expect(getHTML()).toMatch("bar");
|
|
});
|
|
});
|