mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
Fix plugin tests
This commit is contained in:
parent
47d98470b7
commit
91f7b681f4
@ -20,19 +20,15 @@ describe("Mouse Tracking Extension", () => {
|
||||
},
|
||||
];
|
||||
|
||||
const { displayElement, getHTML, getData, expectFinished } = await startTimeline(
|
||||
timeline,
|
||||
jsPsych
|
||||
);
|
||||
const { displayElement, getData, expectFinished } = await startTimeline(timeline, jsPsych);
|
||||
|
||||
const targetRect = displayElement.querySelector("#target").getBoundingClientRect();
|
||||
|
||||
mouseMove(50, 50, displayElement.querySelector("#target"));
|
||||
mouseMove(55, 50, displayElement.querySelector("#target"));
|
||||
mouseMove(60, 50, displayElement.querySelector("#target"));
|
||||
|
||||
pressKey("a");
|
||||
await mouseMove(50, 50, displayElement.querySelector("#target"));
|
||||
await mouseMove(55, 50, displayElement.querySelector("#target"));
|
||||
await mouseMove(60, 50, displayElement.querySelector("#target"));
|
||||
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
|
||||
expect(getData().values()[0].mouse_tracking_data[0]).toMatchObject({
|
||||
@ -70,19 +66,15 @@ describe("Mouse Tracking Extension", () => {
|
||||
},
|
||||
];
|
||||
|
||||
const { displayElement, getHTML, getData, expectFinished } = await startTimeline(
|
||||
timeline,
|
||||
jsPsych
|
||||
);
|
||||
const { displayElement, getData, expectFinished } = await startTimeline(timeline, jsPsych);
|
||||
|
||||
const targetRect = displayElement.querySelector("#target").getBoundingClientRect();
|
||||
|
||||
mouseDown(50, 50, displayElement.querySelector("#target"));
|
||||
mouseDown(55, 50, displayElement.querySelector("#target"));
|
||||
mouseDown(60, 50, displayElement.querySelector("#target"));
|
||||
|
||||
pressKey("a");
|
||||
await mouseDown(50, 50, displayElement.querySelector("#target"));
|
||||
await mouseDown(55, 50, displayElement.querySelector("#target"));
|
||||
await mouseDown(60, 50, displayElement.querySelector("#target"));
|
||||
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
|
||||
expect(getData().values()[0].mouse_tracking_data[0]).toMatchObject({
|
||||
@ -120,19 +112,15 @@ describe("Mouse Tracking Extension", () => {
|
||||
},
|
||||
];
|
||||
|
||||
const { displayElement, getHTML, getData, expectFinished } = await startTimeline(
|
||||
timeline,
|
||||
jsPsych
|
||||
);
|
||||
const { displayElement, getData, expectFinished } = await startTimeline(timeline, jsPsych);
|
||||
|
||||
const targetRect = displayElement.querySelector("#target").getBoundingClientRect();
|
||||
|
||||
mouseUp(50, 50, displayElement.querySelector("#target"));
|
||||
mouseUp(55, 50, displayElement.querySelector("#target"));
|
||||
mouseUp(60, 50, displayElement.querySelector("#target"));
|
||||
|
||||
pressKey("a");
|
||||
await mouseUp(50, 50, displayElement.querySelector("#target"));
|
||||
await mouseUp(55, 50, displayElement.querySelector("#target"));
|
||||
await mouseUp(60, 50, displayElement.querySelector("#target"));
|
||||
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
|
||||
expect(getData().values()[0].mouse_tracking_data[0]).toMatchObject({
|
||||
@ -170,19 +158,15 @@ describe("Mouse Tracking Extension", () => {
|
||||
},
|
||||
];
|
||||
|
||||
const { displayElement, getHTML, getData, expectFinished } = await startTimeline(
|
||||
timeline,
|
||||
jsPsych
|
||||
);
|
||||
const { displayElement, getData, expectFinished } = await startTimeline(timeline, jsPsych);
|
||||
|
||||
const targetRect = displayElement.querySelector("#target").getBoundingClientRect();
|
||||
|
||||
mouseMove(50, 50, displayElement.querySelector("#target"));
|
||||
mouseMove(55, 50, displayElement.querySelector("#target"));
|
||||
mouseDown(60, 50, displayElement.querySelector("#target"));
|
||||
|
||||
pressKey("a");
|
||||
await mouseMove(50, 50, displayElement.querySelector("#target"));
|
||||
await mouseMove(55, 50, displayElement.querySelector("#target"));
|
||||
await mouseDown(60, 50, displayElement.querySelector("#target"));
|
||||
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
|
||||
expect(getData().values()[0].mouse_tracking_data.length).toBe(1);
|
||||
@ -212,16 +196,12 @@ describe("Mouse Tracking Extension", () => {
|
||||
},
|
||||
];
|
||||
|
||||
const { displayElement, getHTML, getData, expectFinished } = await startTimeline(
|
||||
timeline,
|
||||
jsPsych
|
||||
);
|
||||
const { displayElement, getData, expectFinished } = await startTimeline(timeline, jsPsych);
|
||||
|
||||
const targetRect = displayElement.querySelector("#target").getBoundingClientRect();
|
||||
const target2Rect = displayElement.querySelector("#target2").getBoundingClientRect();
|
||||
|
||||
pressKey("a");
|
||||
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
|
||||
expect(getData().values()[0].mouse_tracking_targets["#target"]).toEqual(targetRect);
|
||||
@ -241,25 +221,21 @@ describe("Mouse Tracking Extension", () => {
|
||||
},
|
||||
];
|
||||
|
||||
const { displayElement, getHTML, getData, expectFinished } = await startTimeline(
|
||||
timeline,
|
||||
jsPsych
|
||||
);
|
||||
const { displayElement, getData, expectFinished } = await startTimeline(timeline, jsPsych);
|
||||
|
||||
const targetRect = displayElement.querySelector("#target").getBoundingClientRect();
|
||||
|
||||
mouseMove(50, 50, displayElement.querySelector("#target"));
|
||||
await mouseMove(50, 50, displayElement.querySelector("#target"));
|
||||
jest.advanceTimersByTime(50);
|
||||
|
||||
// this one should be ignored
|
||||
mouseMove(55, 50, displayElement.querySelector("#target"));
|
||||
await mouseMove(55, 50, displayElement.querySelector("#target"));
|
||||
jest.advanceTimersByTime(50);
|
||||
|
||||
// this one should register
|
||||
mouseMove(60, 50, displayElement.querySelector("#target"));
|
||||
|
||||
pressKey("a");
|
||||
await mouseMove(60, 50, displayElement.querySelector("#target"));
|
||||
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
|
||||
expect(getData().values()[0].mouse_tracking_data[0]).toMatchObject({
|
||||
|
@ -59,6 +59,13 @@ describe("ExtensionManager", () => {
|
||||
expect(manager.extensions.test.initialize).toHaveBeenCalledTimes(1);
|
||||
expect(manager.extensions.test.initialize).toHaveBeenCalledWith({ option: 1 });
|
||||
});
|
||||
|
||||
it("defaults `params` to an empty object", async () => {
|
||||
const manager = new ExtensionManager(dependencies, [{ type: TestExtension }]);
|
||||
|
||||
await manager.initializeExtensions();
|
||||
expect(manager.extensions.test.initialize).toHaveBeenCalledWith({});
|
||||
});
|
||||
});
|
||||
|
||||
describe("onStart()", () => {
|
||||
|
@ -40,7 +40,7 @@ export class ExtensionManager {
|
||||
|
||||
public async initializeExtensions() {
|
||||
await Promise.all(
|
||||
this.extensionsConfiguration.map(({ type, params }) =>
|
||||
this.extensionsConfiguration.map(({ type, params = {} }) =>
|
||||
this.getExtensionInstanceByClass(type).initialize(params)
|
||||
)
|
||||
);
|
||||
|
@ -126,7 +126,7 @@ describe("browser-check", () => {
|
||||
expect(getHTML()).toMatch("1200");
|
||||
expect(getHTML()).toMatch("1000");
|
||||
|
||||
clickTarget(displayElement.querySelector("button"));
|
||||
await clickTarget(displayElement.querySelector("button"));
|
||||
|
||||
jest.runAllTimers();
|
||||
|
||||
@ -152,7 +152,7 @@ describe("browser-check", () => {
|
||||
|
||||
expect(displayElement.querySelector("button").innerHTML).toMatch("foo");
|
||||
|
||||
clickTarget(displayElement.querySelector("button"));
|
||||
await clickTarget(displayElement.querySelector("button"));
|
||||
|
||||
jest.runAllTimers();
|
||||
|
||||
|
@ -75,7 +75,7 @@ describe("categorize-animation plugin", () => {
|
||||
]);
|
||||
|
||||
jest.advanceTimersByTime(1000);
|
||||
pressKey("d");
|
||||
await pressKey("d");
|
||||
jest.advanceTimersByTime(1000);
|
||||
expect(getHTML()).toBe("Correct.");
|
||||
});
|
||||
@ -94,7 +94,7 @@ describe("categorize-animation plugin", () => {
|
||||
]);
|
||||
|
||||
jest.advanceTimersByTime(1000);
|
||||
pressKey("s");
|
||||
await pressKey("s");
|
||||
jest.advanceTimersByTime(1000);
|
||||
expect(getHTML()).toBe("Wrong.");
|
||||
});
|
||||
@ -116,7 +116,7 @@ describe("categorize-animation plugin", () => {
|
||||
]);
|
||||
|
||||
jest.advanceTimersByTime(1000);
|
||||
pressKey("d");
|
||||
await pressKey("d");
|
||||
jest.advanceTimersByTime(1000);
|
||||
expect(getHTML()).toBe("<p>Correct. The faces had different expressions.</p>");
|
||||
});
|
||||
@ -137,7 +137,7 @@ describe("categorize-animation plugin", () => {
|
||||
]);
|
||||
|
||||
jest.advanceTimersByTime(1000);
|
||||
pressKey("d");
|
||||
await pressKey("d");
|
||||
jest.advanceTimersByTime(1000);
|
||||
expect(getHTML()).toBe("<p>You pressed the correct key</p>");
|
||||
});
|
||||
@ -158,7 +158,7 @@ describe("categorize-animation plugin", () => {
|
||||
]);
|
||||
|
||||
jest.advanceTimersByTime(1500);
|
||||
pressKey("s");
|
||||
await pressKey("s");
|
||||
jest.advanceTimersByTime(1000);
|
||||
expect(getHTML()).toBe("<p>Incorrect. You pressed the wrong key.</p>");
|
||||
});
|
||||
@ -240,7 +240,7 @@ describe("categorize-animation plugin", () => {
|
||||
]);
|
||||
|
||||
jest.advanceTimersByTime(500);
|
||||
pressKey("d");
|
||||
await pressKey("d");
|
||||
jest.advanceTimersByTime(1000);
|
||||
expect(getHTML()).toEqual(
|
||||
'<img src="img/sad_face_1.jpg" class="jspsych-categorize-animation-stimulus"><p>You pressed the correct key</p>'
|
||||
@ -265,7 +265,7 @@ describe("categorize-animation plugin", () => {
|
||||
]);
|
||||
|
||||
jest.advanceTimersByTime(1000);
|
||||
pressKey("d");
|
||||
await pressKey("d");
|
||||
jest.advanceTimersByTime(500);
|
||||
expect(getHTML()).toBe("<p>You pressed the correct key</p>");
|
||||
jest.advanceTimersByTime(2000);
|
||||
|
@ -16,7 +16,7 @@ describe("categorize-html plugin", () => {
|
||||
]);
|
||||
|
||||
expect(getHTML()).toMatch("FOO");
|
||||
pressKey("d");
|
||||
await pressKey("d");
|
||||
expect(getHTML()).toMatch("Correct");
|
||||
jest.advanceTimersByTime(2000);
|
||||
|
||||
|
@ -16,7 +16,7 @@ describe("categorize-image plugin", () => {
|
||||
]);
|
||||
|
||||
expect(getHTML()).toMatch("FOO.png");
|
||||
pressKey("d");
|
||||
await pressKey("d");
|
||||
expect(getHTML()).toMatch("Correct");
|
||||
jest.advanceTimersByTime(2000);
|
||||
|
||||
|
@ -55,7 +55,7 @@ describe("cloze", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -69,7 +69,7 @@ describe("cloze", () => {
|
||||
]);
|
||||
|
||||
getInputElementById("input0").value = "cloze";
|
||||
clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -83,7 +83,7 @@ describe("cloze", () => {
|
||||
]);
|
||||
|
||||
getInputElementById("input0").value = "filler";
|
||||
clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -97,7 +97,7 @@ describe("cloze", () => {
|
||||
]);
|
||||
|
||||
getInputElementById("input0").value = "some wrong answer";
|
||||
clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await expectRunning();
|
||||
});
|
||||
|
||||
@ -111,7 +111,7 @@ describe("cloze", () => {
|
||||
]);
|
||||
|
||||
getInputElementById("input0").value = "";
|
||||
clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await expectRunning();
|
||||
});
|
||||
|
||||
@ -128,7 +128,7 @@ describe("cloze", () => {
|
||||
]);
|
||||
|
||||
getInputElementById("input0").value = "cloze";
|
||||
clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
expect(mistakeFn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@ -145,7 +145,7 @@ describe("cloze", () => {
|
||||
]);
|
||||
|
||||
getInputElementById("input0").value = "cloze";
|
||||
clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
expect(mistakeFn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@ -162,7 +162,7 @@ describe("cloze", () => {
|
||||
]);
|
||||
|
||||
getInputElementById("input0").value = "some wrong answer";
|
||||
clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
expect(mistakeFn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@ -179,7 +179,7 @@ describe("cloze", () => {
|
||||
]);
|
||||
|
||||
getInputElementById("input0").value = "";
|
||||
clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
expect(mistakeFn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@ -193,7 +193,7 @@ describe("cloze", () => {
|
||||
|
||||
getInputElementById("input0").value = "cloze1";
|
||||
getInputElementById("input1").value = "cloze2";
|
||||
clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
await clickTarget(document.querySelector("#finish_cloze_button"));
|
||||
|
||||
const data = getData().values()[0].response;
|
||||
expect(data.length).toBe(2);
|
||||
|
@ -24,7 +24,7 @@ describe("external-html", () => {
|
||||
await expectRunning();
|
||||
|
||||
expect(getHTML()).toMatch("This is external HTML");
|
||||
clickTarget(displayElement.querySelector("#finished"));
|
||||
await clickTarget(displayElement.querySelector("#finished"));
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
|
@ -20,7 +20,7 @@ describe("fullscreen plugin", () => {
|
||||
]);
|
||||
|
||||
expect(document.documentElement.requestFullscreen).not.toHaveBeenCalled();
|
||||
clickTarget(document.querySelector("#jspsych-fullscreen-btn"));
|
||||
await clickTarget(document.querySelector("#jspsych-fullscreen-btn"));
|
||||
expect(document.documentElement.requestFullscreen).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
@ -58,7 +58,7 @@ describe("html-button-response", () => {
|
||||
'<div id="jspsych-html-button-response-stimulus">this is html</div>'
|
||||
);
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-html-button-response-button-0"));
|
||||
await clickTarget(document.querySelector("#jspsych-html-button-response-button-0"));
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
@ -130,7 +130,7 @@ describe("html-button-response", () => {
|
||||
'<div id="jspsych-html-button-response-stimulus">this is html</div>'
|
||||
);
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-html-button-response-button-0"));
|
||||
await clickTarget(document.querySelector("#jspsych-html-button-response-button-0"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -148,7 +148,7 @@ describe("html-button-response", () => {
|
||||
'<div id="jspsych-html-button-response-stimulus">this is html</div>'
|
||||
);
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-html-button-response-button-0"));
|
||||
await clickTarget(document.querySelector("#jspsych-html-button-response-button-0"));
|
||||
expect(document.querySelector("#jspsych-html-button-response-stimulus").className).toBe(
|
||||
" responded"
|
||||
);
|
||||
|
@ -14,7 +14,7 @@ describe("html-keyboard-response", () => {
|
||||
]);
|
||||
|
||||
expect(getHTML()).toBe('<div id="jspsych-html-keyboard-response-stimulus">this is html</div>');
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -30,7 +30,7 @@ describe("html-keyboard-response", () => {
|
||||
'<div id="jspsych-html-keyboard-response-stimulus">this is html</div>'
|
||||
);
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -48,7 +48,7 @@ describe("html-keyboard-response", () => {
|
||||
'<div id="jspsych-html-keyboard-response-stimulus">this is html</div><div id="foo">this is a prompt</div>'
|
||||
);
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -74,7 +74,7 @@ describe("html-keyboard-response", () => {
|
||||
.visibility
|
||||
).toBe("hidden");
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -107,7 +107,7 @@ describe("html-keyboard-response", () => {
|
||||
'<div id="jspsych-html-keyboard-response-stimulus">this is html</div>'
|
||||
);
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -125,7 +125,7 @@ describe("html-keyboard-response", () => {
|
||||
'<div id="jspsych-html-keyboard-response-stimulus">this is html</div>'
|
||||
);
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
|
||||
expect(document.querySelector("#jspsych-html-keyboard-response-stimulus").className).toBe(
|
||||
" responded"
|
||||
|
@ -137,7 +137,7 @@ describe("html-slider-response", () => {
|
||||
'<div id="jspsych-html-slider-response-stimulus">this is html</div>'
|
||||
);
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-html-slider-response-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-html-slider-response-next"));
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ describe("iat-html plugin", () => {
|
||||
|
||||
expect(getHTML()).toContain('<p id="jspsych-iat-stim"></p><p>dogs</p><p></p>');
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -39,10 +39,10 @@ describe("iat-html plugin", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
pressKey(" ");
|
||||
await pressKey(" ");
|
||||
expect(getHTML()).toContain('<p id="jspsych-iat-stim"></p><p>hello</p><p></p>');
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -58,10 +58,10 @@ describe("iat-html plugin", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
pressKey(" ");
|
||||
await pressKey(" ");
|
||||
expect(getHTML()).toContain('<p id="jspsych-iat-stim"></p><p>hello</p><p></p>');
|
||||
|
||||
pressKey("j");
|
||||
await pressKey("j");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -80,10 +80,10 @@ describe("iat-html plugin", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
expect(getHTML()).toContain('<p id="jspsych-iat-stim" class=" responded"></p><p>hello</p>');
|
||||
|
||||
pressKey(" ");
|
||||
await pressKey(" ");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -102,10 +102,10 @@ describe("iat-html plugin", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
pressKey("j");
|
||||
await pressKey("j");
|
||||
expect(getHTML()).toContain('<p id="jspsych-iat-stim" class=" responded"></p><p>hello</p>');
|
||||
|
||||
pressKey("x");
|
||||
await pressKey("x");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -125,7 +125,7 @@ describe("iat-html plugin", () => {
|
||||
expect(getHTML()).toContain("<p>Press j for:<br> <b>UNFRIENDLY</b>");
|
||||
expect(getHTML()).toContain("<p>Press f for:<br> <b>FRIENDLY</b>");
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -150,10 +150,10 @@ describe("iat-html plugin", () => {
|
||||
|
||||
expect(wrongImageContainer.style.visibility).toBe("hidden");
|
||||
|
||||
pressKey("j");
|
||||
await pressKey("j");
|
||||
expect(wrongImageContainer.style.visibility).toBe("visible");
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -191,7 +191,7 @@ describe("iat-html plugin", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
expect(getHTML()).toContain('<p id="jspsych-iat-stim" class=" responded"></p><p>hello</p>');
|
||||
|
||||
await expectRunning();
|
||||
@ -218,7 +218,7 @@ describe("iat-html plugin", () => {
|
||||
|
||||
jest.advanceTimersByTime(500);
|
||||
|
||||
pressKey("i");
|
||||
await pressKey("i");
|
||||
expect(displayElement.querySelector<HTMLElement>("#wrongImgContainer").style.visibility).toBe(
|
||||
"visible"
|
||||
);
|
||||
@ -247,14 +247,14 @@ describe("iat-html plugin", () => {
|
||||
|
||||
expect(getHTML()).toContain('<p id="jspsych-iat-stim"></p><p>hello</p>');
|
||||
|
||||
pressKey("i");
|
||||
await pressKey("i");
|
||||
expect(getHTML()).toContain('<p id="jspsych-iat-stim" class=" responded"></p><p>hello</p>');
|
||||
|
||||
jest.advanceTimersByTime(1000);
|
||||
expect(getHTML()).toContain('<p id="jspsych-iat-stim" class=" responded"></p><p>hello</p>');
|
||||
|
||||
jest.advanceTimersByTime(500);
|
||||
pressKey("e");
|
||||
await pressKey("e");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -276,7 +276,7 @@ describe("iat-html plugin", () => {
|
||||
]);
|
||||
|
||||
expect(getHTML()).toContain('<p id="jspsych-iat-stim"></p><p>dogs</p><p></p>');
|
||||
pressKey("j");
|
||||
await pressKey("j");
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ describe("iat-image plugin", () => {
|
||||
|
||||
expect(getHTML()).toContain("blue.png");
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -39,10 +39,10 @@ describe("iat-image plugin", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
pressKey("j");
|
||||
await pressKey("j");
|
||||
expect(getHTML()).toContain('<img src="../media/blue.png" id="jspsych-iat-stim">');
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -58,10 +58,10 @@ describe("iat-image plugin", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
expect(getHTML()).toContain('<img src="../media/blue.png" id="jspsych-iat-stim">');
|
||||
|
||||
pressKey("j");
|
||||
await pressKey("j");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -80,12 +80,12 @@ describe("iat-image plugin", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
expect(getHTML()).toContain(
|
||||
'<img src="../media/blue.png" id="jspsych-iat-stim" class=" responded">'
|
||||
);
|
||||
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -104,12 +104,12 @@ describe("iat-image plugin", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
pressKey("j");
|
||||
await pressKey("j");
|
||||
expect(getHTML()).toContain(
|
||||
'<img src="../media/blue.png" id="jspsych-iat-stim" class=" responded">'
|
||||
);
|
||||
|
||||
pressKey("x");
|
||||
await pressKey("x");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -129,7 +129,7 @@ describe("iat-image plugin", () => {
|
||||
expect(getHTML()).toContain("<p>Press j for:<br> <b>UNFRIENDLY</b>");
|
||||
expect(getHTML()).toContain("<p>Press f for:<br> <b>FRIENDLY</b>");
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -152,10 +152,10 @@ describe("iat-image plugin", () => {
|
||||
|
||||
const wrongImageContainer = displayElement.querySelector<HTMLElement>("#wrongImgContainer");
|
||||
expect(wrongImageContainer.style.visibility).toBe("hidden");
|
||||
pressKey("j");
|
||||
await pressKey("j");
|
||||
expect(wrongImageContainer.style.visibility).toBe("visible");
|
||||
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -193,7 +193,7 @@ describe("iat-image plugin", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
expect(getHTML()).toContain(
|
||||
'<img src="../media/blue.png" id="jspsych-iat-stim" class=" responded">'
|
||||
);
|
||||
@ -242,7 +242,7 @@ describe("iat-image plugin", () => {
|
||||
|
||||
jest.advanceTimersByTime(500);
|
||||
|
||||
pressKey("i");
|
||||
await pressKey("i");
|
||||
expect(displayElement.querySelector<HTMLElement>("#wrongImgContainer").style.visibility).toBe(
|
||||
"visible"
|
||||
);
|
||||
@ -294,7 +294,7 @@ describe("iat-image plugin", () => {
|
||||
|
||||
expect(getHTML()).toContain('<img src="../media/blue.png" id="jspsych-iat-stim">');
|
||||
|
||||
pressKey("i");
|
||||
await pressKey("i");
|
||||
expect(getHTML()).toContain(
|
||||
'<img src="../media/blue.png" id="jspsych-iat-stim" class=" responded">'
|
||||
);
|
||||
@ -307,7 +307,7 @@ describe("iat-image plugin", () => {
|
||||
|
||||
jest.advanceTimersByTime(500);
|
||||
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -329,7 +329,7 @@ describe("iat-image plugin", () => {
|
||||
]);
|
||||
|
||||
expect(getHTML()).toContain("blue.png");
|
||||
pressKey("j");
|
||||
await pressKey("j");
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
|
@ -60,7 +60,7 @@ describe("image-button-response", () => {
|
||||
'<img src="../media/blue.png" id="jspsych-image-button-response-stimulus"'
|
||||
);
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-image-button-response-button-0"));
|
||||
await clickTarget(document.querySelector("#jspsych-image-button-response-button-0"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -132,7 +132,7 @@ describe("image-button-response", () => {
|
||||
'<img src="../media/blue.png" id="jspsych-image-button-response-stimulus"'
|
||||
);
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-image-button-response-button-0"));
|
||||
await clickTarget(document.querySelector("#jspsych-image-button-response-button-0"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
|
@ -18,7 +18,7 @@ describe("image-keyboard-response", () => {
|
||||
'<img src="../media/blue.png" id="jspsych-image-keyboard-response-stimulus"'
|
||||
);
|
||||
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -36,7 +36,7 @@ describe("image-keyboard-response", () => {
|
||||
'<img src="../media/blue.png" id="jspsych-image-keyboard-response-stimulus"'
|
||||
);
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -52,7 +52,7 @@ describe("image-keyboard-response", () => {
|
||||
]);
|
||||
|
||||
expect(getHTML()).toContain('<div id="foo">this is a prompt</div>');
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -76,7 +76,7 @@ describe("image-keyboard-response", () => {
|
||||
jest.advanceTimersByTime(500);
|
||||
expect(stimulusElement.style.visibility).toContain("hidden");
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -113,7 +113,7 @@ describe("image-keyboard-response", () => {
|
||||
'<img src="../media/blue.png" id="jspsych-image-keyboard-response-stimulus"'
|
||||
);
|
||||
|
||||
pressKey("f");
|
||||
await pressKey("f");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
|
@ -19,7 +19,7 @@ describe("image-slider-response", () => {
|
||||
expect(getHTML()).toContain(
|
||||
'<div id="jspsych-image-slider-response-stimulus"><img src="../media/blue.png"'
|
||||
);
|
||||
clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -37,7 +37,7 @@ describe("image-slider-response", () => {
|
||||
expect(getHTML()).toContain('<span style="text-align: center; font-size: 80%;">left</span>');
|
||||
expect(getHTML()).toContain('<span style="text-align: center; font-size: 80%;">right</span>');
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -56,7 +56,7 @@ describe("image-slider-response", () => {
|
||||
'<button id="jspsych-image-slider-response-next" class="jspsych-btn">button</button>'
|
||||
);
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -82,7 +82,7 @@ describe("image-slider-response", () => {
|
||||
expect(responseElement.max).toBe("10");
|
||||
expect(responseElement.step).toBe("2");
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -100,7 +100,7 @@ describe("image-slider-response", () => {
|
||||
|
||||
expect(getHTML()).toContain("<p>This is a prompt</p>");
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -123,7 +123,7 @@ describe("image-slider-response", () => {
|
||||
jest.advanceTimersByTime(500);
|
||||
expect(stimulusElement.style.visibility).toContain("hidden");
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -163,7 +163,7 @@ describe("image-slider-response", () => {
|
||||
'<div id="jspsych-image-slider-response-stimulus"><img src="../media/blue.png"'
|
||||
);
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-image-slider-response-next"));
|
||||
await expectFinished();
|
||||
});
|
||||
});
|
||||
|
@ -16,10 +16,10 @@ describe("instructions plugin", () => {
|
||||
|
||||
expect(getHTML()).toContain("page 1");
|
||||
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
expect(getHTML()).toContain("page 2");
|
||||
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -35,13 +35,13 @@ describe("instructions plugin", () => {
|
||||
|
||||
expect(getHTML()).toContain("page 1");
|
||||
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
expect(getHTML()).toContain("page 2");
|
||||
|
||||
pressKey("ArrowLeft");
|
||||
await pressKey("ArrowLeft");
|
||||
expect(getHTML()).toContain("page 2");
|
||||
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -54,8 +54,8 @@ describe("instructions plugin", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
pressKey("a");
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
await pressKey("a");
|
||||
|
||||
await expectFinished();
|
||||
|
||||
|
@ -18,7 +18,7 @@ describe("maxdiff plugin", () => {
|
||||
document.querySelector<HTMLInputElement>('input[data-name="0"][name="left"]').checked = true;
|
||||
document.querySelector<HTMLInputElement>('input[data-name="1"][name="right"]').checked = true;
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-maxdiff-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-maxdiff-next"));
|
||||
await expectFinished();
|
||||
|
||||
expect(getData().values()[0].response).toEqual({ left: "a", right: "b" });
|
||||
|
@ -1,7 +1,7 @@
|
||||
import audioKeyboardResponse from "@jspsych/plugin-audio-keyboard-response";
|
||||
import imageKeyboardResponse from "@jspsych/plugin-image-keyboard-response";
|
||||
import videoKeyboardResponse from "@jspsych/plugin-video-keyboard-response";
|
||||
import { simulateTimeline, startTimeline } from "@jspsych/test-utils";
|
||||
import { flushPromises, simulateTimeline, startTimeline } from "@jspsych/test-utils";
|
||||
import { JsPsych, initJsPsych } from "jspsych";
|
||||
|
||||
import preloadPlugin from ".";
|
||||
@ -573,6 +573,7 @@ describe("preload plugin", () => {
|
||||
);
|
||||
|
||||
jest.advanceTimersByTime(101);
|
||||
await flushPromises();
|
||||
|
||||
expect(mockFn).toHaveBeenCalledWith("timeout");
|
||||
expect(getHTML()).toMatch(
|
||||
|
@ -49,9 +49,9 @@ describe("reconstruction", () => {
|
||||
|
||||
const { getHTML } = await startTimeline(timeline);
|
||||
|
||||
pressKey("h");
|
||||
await pressKey("h");
|
||||
expect(getHTML()).toContain("<p>6</p>");
|
||||
pressKey("h");
|
||||
await pressKey("h");
|
||||
expect(getHTML()).toContain("<p>7</p>");
|
||||
});
|
||||
|
||||
@ -68,9 +68,9 @@ describe("reconstruction", () => {
|
||||
|
||||
const { getHTML } = await startTimeline(timeline);
|
||||
|
||||
pressKey("g");
|
||||
await pressKey("g");
|
||||
expect(getHTML()).toContain("<p>4</p>");
|
||||
pressKey("g");
|
||||
await pressKey("g");
|
||||
expect(getHTML()).toContain("<p>3</p>");
|
||||
});
|
||||
|
||||
@ -88,11 +88,11 @@ describe("reconstruction", () => {
|
||||
|
||||
const { getHTML } = await startTimeline(timeline);
|
||||
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
expect(getHTML()).toContain("<p>6</p>");
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
expect(getHTML()).toContain("<p>7</p>");
|
||||
pressKey("h");
|
||||
await pressKey("h");
|
||||
expect(getHTML()).toContain("<p>7</p>");
|
||||
});
|
||||
|
||||
@ -110,11 +110,11 @@ describe("reconstruction", () => {
|
||||
|
||||
const { getHTML } = await startTimeline(timeline);
|
||||
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
expect(getHTML()).toContain("<p>4</p>");
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
expect(getHTML()).toContain("<p>3</p>");
|
||||
pressKey("g");
|
||||
await pressKey("g");
|
||||
expect(getHTML()).toContain("<p>3</p>");
|
||||
});
|
||||
|
||||
@ -147,7 +147,7 @@ describe("reconstruction", () => {
|
||||
|
||||
const { displayElement, expectFinished } = await startTimeline(timeline);
|
||||
|
||||
clickTarget(displayElement.querySelector("button"));
|
||||
await clickTarget(displayElement.querySelector("button"));
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
@ -165,9 +165,9 @@ describe("reconstruction", () => {
|
||||
|
||||
const { displayElement, getData } = await startTimeline(timeline);
|
||||
|
||||
pressKey("h");
|
||||
await pressKey("h");
|
||||
|
||||
clickTarget(displayElement.querySelector("button"));
|
||||
await clickTarget(displayElement.querySelector("button"));
|
||||
|
||||
expect(getData().values()[0].final_value).toEqual(0.55);
|
||||
});
|
||||
|
@ -28,7 +28,7 @@ describe("same-different-html", () => {
|
||||
|
||||
expect(getHTML()).toMatch("visibility: hidden");
|
||||
|
||||
pressKey("q"); // same_key
|
||||
await pressKey("q"); // same_key
|
||||
await expectFinished();
|
||||
|
||||
expect(getData().values()[0].correct).toBe(true);
|
||||
|
@ -28,7 +28,7 @@ describe("same-different-image", () => {
|
||||
|
||||
expect(getHTML()).toMatch("visibility: hidden");
|
||||
|
||||
pressKey("q"); // same_key
|
||||
await pressKey("q"); // same_key
|
||||
await expectFinished();
|
||||
|
||||
expect(getData().values()[0].correct).toBe(true);
|
||||
|
@ -21,7 +21,7 @@ describe("serial-reaction-time plugin", () => {
|
||||
expect(getCellElement("0-2").style.backgroundColor).toBe("");
|
||||
expect(getCellElement("0-3").style.backgroundColor).toBe("");
|
||||
|
||||
pressKey("3");
|
||||
await pressKey("3");
|
||||
|
||||
await expectFinished();
|
||||
expect(getData().last(1).values()[0].correct).toBe(true);
|
||||
@ -42,7 +42,7 @@ describe("serial-reaction-time plugin", () => {
|
||||
expect(getCellElement("0-2").style.backgroundColor).toBe("");
|
||||
expect(getCellElement("0-3").style.backgroundColor).toBe("");
|
||||
|
||||
pressKey("3");
|
||||
await pressKey("3");
|
||||
|
||||
expect(getHTML()).not.toBe("");
|
||||
|
||||
@ -69,7 +69,7 @@ describe("serial-reaction-time plugin", () => {
|
||||
expect(getCellElement("0-2").style.backgroundColor).toBe("");
|
||||
expect(getCellElement("0-3").style.backgroundColor).toBe("");
|
||||
|
||||
pressKey("3");
|
||||
await pressKey("3");
|
||||
|
||||
jest.runAllTimers();
|
||||
|
||||
@ -78,7 +78,7 @@ describe("serial-reaction-time plugin", () => {
|
||||
expect(getCellElement("0-2").style.backgroundColor).toBe("");
|
||||
expect(getCellElement("0-3").style.backgroundColor).toBe("");
|
||||
|
||||
pressKey("3");
|
||||
await pressKey("3");
|
||||
|
||||
await expectFinished();
|
||||
|
||||
|
@ -19,7 +19,7 @@ describe("sketchpad", () => {
|
||||
expect(displayElement.querySelector("#sketchpad-undo")).not.toBeNull();
|
||||
expect(displayElement.querySelector("#sketchpad-redo")).not.toBeNull();
|
||||
|
||||
clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -36,7 +36,7 @@ describe("sketchpad", () => {
|
||||
expect(canvas.getAttribute("width")).toBe("800");
|
||||
expect(canvas.getAttribute("height")).toBe("300");
|
||||
|
||||
clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -54,7 +54,7 @@ describe("sketchpad", () => {
|
||||
expect(canvas.getAttribute("width")).toBe("300");
|
||||
expect(canvas.getAttribute("height")).toBe("300");
|
||||
|
||||
clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -75,7 +75,7 @@ describe("sketchpad", () => {
|
||||
display_content.indexOf("sketchpad-canvas")
|
||||
);
|
||||
|
||||
clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -100,7 +100,7 @@ describe("sketchpad", () => {
|
||||
);
|
||||
expect(display_content.indexOf("prompt")).toBeLessThan(display_content.indexOf("finish-btn"));
|
||||
|
||||
clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -127,7 +127,7 @@ describe("sketchpad", () => {
|
||||
display_content.indexOf("finish-btn")
|
||||
);
|
||||
|
||||
clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -145,7 +145,7 @@ describe("sketchpad", () => {
|
||||
expect(buttons[1].getAttribute("data-color")).toBe("green");
|
||||
expect(buttons[2].getAttribute("data-color")).toBe("#0000ff");
|
||||
|
||||
clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -161,7 +161,7 @@ describe("sketchpad", () => {
|
||||
|
||||
expect(button.innerHTML).toBe("foo");
|
||||
|
||||
clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -177,7 +177,7 @@ describe("sketchpad", () => {
|
||||
|
||||
expect(button.innerHTML).toBe("foo");
|
||||
|
||||
clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -193,7 +193,7 @@ describe("sketchpad", () => {
|
||||
|
||||
expect(button.innerHTML).toBe("foo");
|
||||
|
||||
clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await expectFinished();
|
||||
});
|
||||
|
||||
@ -209,7 +209,7 @@ describe("sketchpad", () => {
|
||||
|
||||
expect(button.innerHTML).toBe("foo");
|
||||
|
||||
clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await clickTarget(displayElement.querySelector("#sketchpad-end"));
|
||||
await expectFinished();
|
||||
});
|
||||
});
|
||||
|
@ -22,7 +22,7 @@ describe("survey-html-form plugin", () => {
|
||||
'#jspsych-survey-html-form input[name="second"]'
|
||||
)[0].value = TEST_VALUE;
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-survey-html-form-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-survey-html-form-next"));
|
||||
|
||||
await expectFinished();
|
||||
|
||||
|
@ -30,7 +30,7 @@ describe("survey-likert plugin", () => {
|
||||
selectInput("Q3", "3").checked = true;
|
||||
selectInput("Q4", "4").checked = true;
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-survey-likert-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-survey-likert-next"));
|
||||
|
||||
await expectFinished();
|
||||
|
||||
|
@ -32,7 +32,7 @@ describe("survey-multi-choice plugin", () => {
|
||||
getInputElement(3, "d").checked = true;
|
||||
getInputElement(4, "e").checked = true;
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-survey-multi-choice-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-survey-multi-choice-next"));
|
||||
|
||||
await expectFinished();
|
||||
|
||||
|
@ -63,7 +63,7 @@ describe("survey-multi-select plugin", () => {
|
||||
getInputElement(3, "d").checked = true;
|
||||
getInputElement(4, "e").checked = true;
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-survey-multi-select-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-survey-multi-select-next"));
|
||||
|
||||
await expectFinished();
|
||||
|
||||
|
@ -19,7 +19,7 @@ describe("survey-text plugin", () => {
|
||||
expect(selectInput("#input-0").size).toBe(40);
|
||||
expect(selectInput("#input-1").size).toBe(40);
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-survey-text-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-survey-text-next"));
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
@ -39,7 +39,7 @@ describe("survey-text plugin", () => {
|
||||
expect(selectInput("#input-0").size).toBe(50);
|
||||
expect(selectInput("#input-1").size).toBe(20);
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-survey-text-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-survey-text-next"));
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
@ -81,7 +81,7 @@ describe("survey-text plugin", () => {
|
||||
selectInput("#input-3").value = "a3";
|
||||
selectInput("#input-4").value = "a4";
|
||||
|
||||
clickTarget(document.querySelector("#jspsych-survey-text-next"));
|
||||
await clickTarget(document.querySelector("#jspsych-survey-text-next"));
|
||||
|
||||
await expectFinished();
|
||||
|
||||
|
@ -52,7 +52,7 @@ describe("survey plugin", () => {
|
||||
const finish_button = displayElement.querySelector("input.sv_complete_btn");
|
||||
expect(finish_button).not.toBeNull();
|
||||
|
||||
clickTarget(finish_button);
|
||||
await clickTarget(finish_button);
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
@ -79,7 +79,7 @@ describe("survey plugin", () => {
|
||||
|
||||
const finish_button = displayElement.querySelector("input.sv_complete_btn");
|
||||
expect(finish_button).not.toBeNull();
|
||||
clickTarget(finish_button);
|
||||
await clickTarget(finish_button);
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
@ -124,7 +124,7 @@ describe("survey plugin", () => {
|
||||
const finish_button = displayElement.querySelector("input.sv_complete_btn");
|
||||
expect(finish_button).not.toBeNull();
|
||||
|
||||
clickTarget(finish_button);
|
||||
await clickTarget(finish_button);
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
@ -156,7 +156,7 @@ describe("survey plugin", () => {
|
||||
|
||||
const finish_button = displayElement.querySelector("input.sv_complete_btn");
|
||||
expect(finish_button).not.toBeNull();
|
||||
clickTarget(finish_button);
|
||||
await clickTarget(finish_button);
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
@ -188,7 +188,7 @@ describe("survey plugin", () => {
|
||||
|
||||
const finish_button = displayElement.querySelector("input.sv_complete_btn");
|
||||
expect(finish_button).not.toBeNull();
|
||||
clickTarget(finish_button);
|
||||
await clickTarget(finish_button);
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
@ -220,7 +220,7 @@ describe("survey plugin", () => {
|
||||
|
||||
const finish_button = displayElement.querySelector("input.sv_complete_btn");
|
||||
expect(finish_button).not.toBeNull();
|
||||
clickTarget(finish_button);
|
||||
await clickTarget(finish_button);
|
||||
|
||||
await expectFinished();
|
||||
});
|
||||
@ -277,7 +277,7 @@ describe("survey plugin", () => {
|
||||
|
||||
const finish_button = displayElement.querySelector("input.sv_complete_btn");
|
||||
expect(finish_button).not.toBeNull();
|
||||
clickTarget(finish_button);
|
||||
await clickTarget(finish_button);
|
||||
|
||||
await expectFinished();
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ const info = <const>{
|
||||
likert_scale_values: {
|
||||
type: ParameterType.COMPLEX,
|
||||
pretty_name: "Likert scale values",
|
||||
default: null,
|
||||
default: [],
|
||||
array: true,
|
||||
},
|
||||
/** Likert only: Minimum rating scale value. */
|
||||
@ -103,7 +103,7 @@ const info = <const>{
|
||||
type: ParameterType.COMPLEX,
|
||||
pretty_name: "Statements",
|
||||
array: true,
|
||||
default: null,
|
||||
default: [],
|
||||
nested: {
|
||||
/** Statement text */
|
||||
prompt: {
|
||||
@ -139,7 +139,7 @@ const info = <const>{
|
||||
options: {
|
||||
type: ParameterType.STRING,
|
||||
pretty_name: "Options",
|
||||
default: null,
|
||||
default: [],
|
||||
array: true,
|
||||
},
|
||||
/** Drop-down/multi-choice/multi-select/ranking only: re-ordering of options array */
|
||||
@ -661,7 +661,7 @@ class SurveyPlugin implements JsPsychPlugin<Info> {
|
||||
|
||||
question.title = params.prompt;
|
||||
question.isRequired = params.required;
|
||||
if (params.likert_scale_values !== null) {
|
||||
if (params.likert_scale_values.length > 0) {
|
||||
question.rateValues = params.likert_scale_values;
|
||||
} else {
|
||||
question.rateMin = params.likert_scale_min;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { pressKey, simulateTimeline, startTimeline } from "@jspsych/test-utils";
|
||||
import { flushPromises, pressKey, simulateTimeline, startTimeline } from "@jspsych/test-utils";
|
||||
|
||||
import visualSearchCircle from ".";
|
||||
|
||||
@ -22,9 +22,10 @@ describe("visual-search-circle", () => {
|
||||
expect(displayElement.querySelectorAll("img").length).toBe(1);
|
||||
|
||||
jest.advanceTimersByTime(1000); // fixation duration
|
||||
await flushPromises();
|
||||
|
||||
expect(displayElement.querySelectorAll("img").length).toBe(5);
|
||||
pressKey("a");
|
||||
await pressKey("a");
|
||||
await expectFinished();
|
||||
|
||||
expect(getData().values()[0].correct).toBe(true);
|
||||
|
@ -25,7 +25,7 @@ const info = <const>{
|
||||
stimuli: {
|
||||
type: ParameterType.IMAGE,
|
||||
pretty_name: "Stimuli",
|
||||
default: null,
|
||||
default: [],
|
||||
array: true,
|
||||
},
|
||||
/**
|
||||
@ -249,7 +249,7 @@ class VisualSearchCirclePlugin implements JsPsychPlugin<Info> {
|
||||
];
|
||||
}
|
||||
|
||||
private generateDisplayLocs(n_locs, trial) {
|
||||
private generateDisplayLocs(n_locs: number, trial: TrialType<Info>) {
|
||||
// circle params
|
||||
var diam = trial.circle_diameter; // pixels
|
||||
var radi = diam / 2;
|
||||
@ -272,7 +272,7 @@ class VisualSearchCirclePlugin implements JsPsychPlugin<Info> {
|
||||
return display_locs;
|
||||
}
|
||||
|
||||
private generatePresentationSet(trial) {
|
||||
private generatePresentationSet(trial: TrialType<Info>) {
|
||||
var to_present = [];
|
||||
if (trial.target !== null && trial.foil !== null && trial.set_size !== null) {
|
||||
if (trial.target_present) {
|
||||
@ -285,7 +285,7 @@ class VisualSearchCirclePlugin implements JsPsychPlugin<Info> {
|
||||
to_present.push(trial.foil);
|
||||
}
|
||||
}
|
||||
} else if (trial.stimuli !== null) {
|
||||
} else if (trial.stimuli.length > 0) {
|
||||
to_present = trial.stimuli;
|
||||
} else {
|
||||
console.error(
|
||||
|
Loading…
Reference in New Issue
Block a user