mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-13 00:58:12 +00:00
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { clickTarget, startTimeline } from "@jspsych/test-utils";
|
|
|
|
import surveyHtmlForm from ".";
|
|
|
|
const TEST_VALUE = "jsPsych";
|
|
|
|
describe("survey-html-form plugin", () => {
|
|
test("default parameters work correctly", async () => {
|
|
const { displayElement, expectFinished, getData } = await startTimeline([
|
|
{
|
|
type: surveyHtmlForm,
|
|
html: '<p> I am feeling <input name="first" type="text" />, <input name="second" type="text" />, and <input name="third" type="text" />.</p>',
|
|
},
|
|
]);
|
|
|
|
expect(
|
|
displayElement.querySelectorAll('#jspsych-survey-html-form input:not([type="submit"]').length
|
|
).toBe(3);
|
|
|
|
// Provide some test input
|
|
displayElement.querySelectorAll<HTMLInputElement>(
|
|
'#jspsych-survey-html-form input[name="second"]'
|
|
)[0].value = TEST_VALUE;
|
|
|
|
clickTarget(document.querySelector("#jspsych-survey-html-form-next"));
|
|
|
|
await expectFinished();
|
|
|
|
// Check whether data is parsed properly
|
|
const data = getData().values()[0].response;
|
|
expect(data.second).toBe(TEST_VALUE);
|
|
});
|
|
});
|