Files
galaxy/client/src/components/Form/Elements/FormBoolean.test.js
T
davelopez 86d6dbdc67 Refactor client tests to use await for mutations
According to Vue Test Utils documentation:
'A nice rule to follow is to always `await` on mutations like `trigger` or `setProps`. If your code relies on something async, like calling axios, add an `await` to the `flushPromises` call as well.'
2022-02-18 12:38:48 +01:00

31 lines
892 B
JavaScript

import { mount } from "@vue/test-utils";
import { getLocalVue } from "jest/helpers";
import FormBoolean from "./FormBoolean";
const localVue = getLocalVue();
describe("FormBoolean", () => {
let wrapper;
beforeEach(() => {
wrapper = mount(FormBoolean, {
propsData: {
value: false,
},
localVue,
});
});
it("check initial value and value change", async () => {
const input = wrapper.find("input");
expect(wrapper.vm.currentValue).toBe(false);
await wrapper.setProps({ value: true });
expect(wrapper.vm.currentValue).toBe(true);
await input.trigger("click");
expect(input.element.checked).toBe(false);
await input.trigger("click");
expect(input.element.checked).toBe(true);
expect(wrapper.emitted().input[0][0]).toBe(true);
});
});