Skip to content

Commit

Permalink
add test for combining survey_json and survey_function parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
becky-gilbert committed Jan 4, 2024
1 parent 335031c commit ab6cb2a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions packages/plugin-survey/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,49 @@ describe("survey plugin", () => {
clickTarget(complete_button);
await expectFinished();
});

test("survey_json can be combined with survey_function", async () => {
const survey_json = {
pages: [
{
name: "test_page",
elements: [
{
type: "radiogroup",
name: "question_1",
choices: [
{ value: 1, text: "Option 1" },
{ value: 2, text: "Option 2" },
],
},
],
},
],
};

const survey_function = (survey) => {
const page = survey.getPageByName("test_page");
page.addNewQuestion("comment", "question_2");
};

const { displayElement, expectRunning, expectFinished, getData } = await startTimeline([
{
type: survey,
survey_json: JSON.stringify(survey_json),
survey_function: survey_function,
},
]);

await expectRunning();

expect(displayElement.querySelector('div[data-name="question_1"]')).not.toBeNull();
expect(displayElement.querySelector('div[data-name="question_2"]')).not.toBeNull();

const complete_button = displayElement.querySelector(
'input[type="button"].sd-navigation__complete-btn'
);
expect(complete_button).not.toBeNull();
clickTarget(complete_button);
await expectFinished();
});
});

0 comments on commit ab6cb2a

Please sign in to comment.