jsPsych/packages/jspsych/tests/core/case-sensitive-responses.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

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();
});
});