diff --git a/client/src/components/Form/Elements/FormRadio.test.js b/client/src/components/Form/Elements/FormRadio.test.ts similarity index 76% rename from client/src/components/Form/Elements/FormRadio.test.js rename to client/src/components/Form/Elements/FormRadio.test.ts index 9328055ec30e..9dc14802f9bc 100644 --- a/client/src/components/Form/Elements/FormRadio.test.js +++ b/client/src/components/Form/Elements/FormRadio.test.ts @@ -1,15 +1,15 @@ -import { mount } from "@vue/test-utils"; -import { getLocalVue } from "tests/jest/helpers"; +import { getLocalVue } from "@tests/jest/helpers"; +import { mount, Wrapper } from "@vue/test-utils"; -import MountTarget from "./FormRadio"; +import MountTarget from "./FormRadio.vue"; const localVue = getLocalVue(true); describe("FormRadio", () => { - let wrapper; + let wrapper: Wrapper; beforeEach(() => { - wrapper = mount(MountTarget, { + wrapper = mount(MountTarget as object, { propsData: { value: false, options: [], @@ -20,21 +20,30 @@ describe("FormRadio", () => { it("basics", async () => { const noInput = wrapper.find("[type='radio']"); + expect(noInput.exists()).toBe(false); + const n = 3; const options = []; + for (let i = 0; i < n; i++) { options.push({ label: `label_${i}`, value: `value_${i}` }); } + await wrapper.setProps({ options }); + const inputs = wrapper.findAll("[type='radio']"); const labels = wrapper.findAll(".custom-control-label"); + expect(inputs.length).toBe(n); + for (let i = 0; i < n; i++) { await inputs.at(i).setChecked(); + expect(labels.at(i).text()).toBe(`label_${i}`); expect(inputs.at(i).attributes("value")).toBe(`value_${i}`); - expect(wrapper.emitted()["input"][i][0]).toBe(`value_${i}`); + + expect(wrapper.emitted()["input"]?.[i]?.[0]).toBe(`value_${i}`); } }); });