mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { jest } from "@jest/globals";
|
|
import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response";
|
|
|
|
import jsPsych from "../../src";
|
|
import { pressKey } from "../utils";
|
|
|
|
jest.useFakeTimers();
|
|
|
|
describe("default iti parameter", function () {
|
|
test("has a default value of 0", function () {
|
|
var t = {
|
|
type: htmlKeyboardResponse,
|
|
stimulus: "foo",
|
|
};
|
|
|
|
var t2 = {
|
|
type: htmlKeyboardResponse,
|
|
stimulus: "bar",
|
|
};
|
|
|
|
jsPsych.init({ timeline: [t, t2] });
|
|
|
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch("foo");
|
|
pressKey("a");
|
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch("bar");
|
|
pressKey("a");
|
|
});
|
|
|
|
test("creates a correct delay when set", function () {
|
|
var t = {
|
|
type: htmlKeyboardResponse,
|
|
stimulus: "foo",
|
|
};
|
|
|
|
var t2 = {
|
|
type: htmlKeyboardResponse,
|
|
stimulus: "bar",
|
|
};
|
|
|
|
jsPsych.init({ timeline: [t, t2], default_iti: 100 });
|
|
|
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch("foo");
|
|
pressKey("a");
|
|
expect(jsPsych.getDisplayElement().innerHTML).not.toMatch("bar");
|
|
jest.advanceTimersByTime(100);
|
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch("bar");
|
|
pressKey("a");
|
|
});
|
|
});
|