mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-11 16:18:11 +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.
38 lines
869 B
TypeScript
38 lines
869 B
TypeScript
import imageKeyboardResponse from "@jspsych/plugin-image-keyboard-response";
|
|
|
|
import { JsPsych, initJsPsych } from "../../src";
|
|
|
|
let jsPsych: JsPsych;
|
|
|
|
describe("getAutoPreloadList", function () {
|
|
test("gets whole timeline when no argument provided", function () {
|
|
var t = {
|
|
type: imageKeyboardResponse,
|
|
stimulus: "img/foo.png",
|
|
render_on_canvas: false,
|
|
};
|
|
|
|
var timeline = [t];
|
|
|
|
jsPsych = initJsPsych({
|
|
timeline: timeline,
|
|
});
|
|
|
|
var images = jsPsych.pluginAPI.getAutoPreloadList().images;
|
|
|
|
expect(images[0]).toBe("img/foo.png");
|
|
});
|
|
test("works with images", function () {
|
|
var t = {
|
|
type: imageKeyboardResponse,
|
|
stimulus: "img/foo.png",
|
|
};
|
|
|
|
var timeline = [t];
|
|
|
|
var images = jsPsych.pluginAPI.getAutoPreloadList(timeline).images;
|
|
|
|
expect(images[0]).toBe("img/foo.png");
|
|
});
|
|
});
|