From 7a19f74f18bc10c17bc39959b1972ff2b95821cc Mon Sep 17 00:00:00 2001 From: guerler Date: Mon, 28 Aug 2023 10:22:39 +0200 Subject: [PATCH] Add additional tests for form data input element --- .../Form/Elements/FormData/FormData.test.js | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/client/src/components/Form/Elements/FormData/FormData.test.js b/client/src/components/Form/Elements/FormData/FormData.test.js index f75ba6f5bcbc..2d4eab65a8af 100644 --- a/client/src/components/Form/Elements/FormData/FormData.test.js +++ b/client/src/components/Form/Elements/FormData/FormData.test.js @@ -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 () => { @@ -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"); }); });