mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +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.
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
// import surveyText from "@jspsych/plugin-survey-text";
|
|
|
|
import { startTimeline } from "../utils";
|
|
|
|
describe("nested defaults", () => {
|
|
test.skip("work in basic situation", async () => {
|
|
const { displayElement } = await startTimeline([
|
|
{
|
|
// @ts-ignore TODO enable this test once the plugin is a class
|
|
type: surveyText,
|
|
questions: [
|
|
{
|
|
prompt: "Question 1.",
|
|
},
|
|
{
|
|
prompt: "Question 2.",
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
|
|
expect(displayElement.querySelector("input").placeholder).toBe("");
|
|
expect(displayElement.querySelector("input").size).toBe(40);
|
|
});
|
|
|
|
test.skip("safe against extending the array.prototype (issue #989)", async () => {
|
|
// @ts-expect-error
|
|
Array.prototype.qq = jest.fn();
|
|
const spy = jest.spyOn(console, "error").mockImplementation();
|
|
|
|
const { displayElement } = await startTimeline([
|
|
{
|
|
// @ts-ignore TODO enable this test once the plugin is a class
|
|
type: surveyText,
|
|
questions: [
|
|
{
|
|
prompt: "Question 1.",
|
|
},
|
|
{
|
|
prompt: "Question 2.",
|
|
},
|
|
],
|
|
},
|
|
]);
|
|
|
|
expect(displayElement.querySelector("input").placeholder).toBe("");
|
|
expect(displayElement.querySelector("input").size).toBe(40);
|
|
|
|
expect(spy).not.toHaveBeenCalled();
|
|
|
|
spy.mockRestore();
|
|
});
|
|
});
|