Skip to content

Commit

Permalink
Add additional tests for form data input element
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Aug 30, 2023
1 parent e61abbf commit 7a19f74
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions client/src/components/Form/Elements/FormData/FormData.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,15 @@ describe("FormData", () => {
const message = wrapper.findAll(".form-data-entry-label");
expect(message.length).toBe(1);
expect(message.at(0).text()).toBe("1. dceName1 (dce)");
expect(wrapper.find(".btn-group").exists()).toBeFalsy();
const closeButton = wrapper.find(".alert .close");
await closeButton.trigger("click");
expect(wrapper.emitted().input[1][0]).toEqual(null);
expect(wrapper.find(".alert").exists()).toBeFalsy();
await wrapper.setProps({ value: null });
const options = wrapper.find(".btn-group").findAll("button");
expect(options.length).toBe(4);
expect(wrapper.emitted().input.length).toEqual(2);
});

it("dataset collection element as hdca without subcollection_type", async () => {
Expand Down Expand Up @@ -300,14 +306,25 @@ describe("FormData", () => {
expect(options.length).toBe(3);
expect(options.at(1).classes()).toContain("active");
expect(options.at(1).attributes("title")).toBe("Dataset collection");
expect(wrapper.emitted().input[1][0]).toEqual({
batch: false,
product: false,
values: [{ id: "hdca4", map_over_type: null, src: "hdca" }],
});
for (const i of [0, 1]) {
expect(wrapper.emitted().input[i][0]).toEqual({
batch: false,
product: false,
values: [{ id: "hdca4", map_over_type: null, src: "hdca" }],
});
}
expect(wrapper.emitted().input.length).toEqual(2);
const selectedValues = wrapper.findAll(SELECTED_VALUE);
expect(selectedValues.length).toBe(1);
expect(selectedValues.at(0).text()).toBe("4: hdcaName4");
await wrapper.find("[title='Multiple datasets'").trigger("click");
expect(options.at(0).classes()).toContain("active");
expect(wrapper.emitted().input[2][0]).toEqual({
batch: false,
product: false,
values: [{ id: "hda3", map_over_type: null, src: "hda" }],
});
const newSelectedValues = wrapper.findAll(SELECTED_VALUE);
expect(newSelectedValues.at(0).text()).toBe("3: hdaName3");
});
});

0 comments on commit 7a19f74

Please sign in to comment.