mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 16:48:12 +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.
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response";
|
|
|
|
import { pressKey, startTimeline } from "../utils";
|
|
|
|
describe("case_sensitive_responses parameter", () => {
|
|
test("has a default value of false", async () => {
|
|
const { getHTML, expectFinished } = await startTimeline([
|
|
{
|
|
type: htmlKeyboardResponse,
|
|
stimulus: "foo",
|
|
choices: ["a"],
|
|
},
|
|
]);
|
|
|
|
expect(getHTML()).toMatch("foo");
|
|
pressKey("A");
|
|
await expectFinished();
|
|
});
|
|
|
|
test("responses are not case sensitive when set to false", async () => {
|
|
const { getHTML, expectFinished } = await startTimeline(
|
|
[
|
|
{
|
|
type: htmlKeyboardResponse,
|
|
stimulus: "foo",
|
|
choices: ["a"],
|
|
},
|
|
],
|
|
{ case_sensitive_responses: false }
|
|
);
|
|
|
|
expect(getHTML()).toMatch("foo");
|
|
pressKey("A");
|
|
await expectFinished();
|
|
});
|
|
|
|
test("responses are case sensitive when set to true", async () => {
|
|
const { getHTML, expectFinished } = await startTimeline(
|
|
[
|
|
{
|
|
type: htmlKeyboardResponse,
|
|
stimulus: "foo",
|
|
choices: ["a"],
|
|
},
|
|
],
|
|
{ case_sensitive_responses: true }
|
|
);
|
|
|
|
expect(getHTML()).toMatch("foo");
|
|
pressKey("A");
|
|
expect(getHTML()).toMatch("foo");
|
|
pressKey("a");
|
|
await expectFinished();
|
|
});
|
|
});
|