mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-13 09:08:13 +00:00

Instead of a global `jsPsych` object, there is a `JsPsych` class now which can be instantiated with the parameters that were previously accepted by `jsPsych.init`. Upon instantiation, the `JsPsych` class also instantiates classes for stateful modules (`jsPsych.data` and `jsPsych.pluginAPI`) and passes relevant `JsPsych` instance information to them. Plugins are expected to be classes now that are instantiated for each trial and receive the `JsPsych` instance as their only constructor argument.
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import htmlKeyboardResponse from "@jspsych/plugin-html-keyboard-response";
|
|
|
|
import { JsPsych, initJsPsych } from "../../src";
|
|
import { pressKey } from "../utils";
|
|
|
|
let jsPsych: JsPsych;
|
|
|
|
describe("case_sensitive_responses parameter", function () {
|
|
test("has a default value of false", function () {
|
|
var t = {
|
|
type: htmlKeyboardResponse,
|
|
stimulus: "foo",
|
|
choices: ["a"],
|
|
};
|
|
|
|
jsPsych = initJsPsych({ timeline: [t] });
|
|
|
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch("foo");
|
|
pressKey("A");
|
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch("");
|
|
});
|
|
|
|
test("responses are not case sensitive when set to false", function () {
|
|
var t = {
|
|
type: htmlKeyboardResponse,
|
|
stimulus: "foo",
|
|
choices: ["a"],
|
|
};
|
|
|
|
jsPsych = initJsPsych({ timeline: [t], case_sensitive_responses: false });
|
|
|
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch("foo");
|
|
pressKey("A");
|
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch("");
|
|
});
|
|
|
|
test("responses are case sensitive when set to true", function () {
|
|
var t = {
|
|
type: htmlKeyboardResponse,
|
|
stimulus: "foo",
|
|
choices: ["a"],
|
|
};
|
|
|
|
jsPsych = initJsPsych({ timeline: [t], case_sensitive_responses: true });
|
|
|
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch("foo");
|
|
pressKey("A");
|
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch("foo");
|
|
pressKey("a");
|
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch("");
|
|
});
|
|
});
|