Files
galaxy/client/src/components/Workflow/Editor/ZoomControl.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

26 lines
821 B
JavaScript

import { mount } from "@vue/test-utils";
import { getLocalVue } from "jest/helpers";
import ZoomControl from "./ZoomControl";
jest.mock("app");
describe("ZoomControl", () => {
it("test zoom control", async () => {
const localVue = getLocalVue();
const wrapper = mount(ZoomControl, {
propsData: {
zoomLevel: 10,
},
localVue,
});
const buttons = wrapper.findAll("button");
expect(buttons.length).toBe(3);
await buttons.at(0).trigger("click");
expect(wrapper.emitted().onZoom[0][0]).toBe(9);
await buttons.at(1).trigger("click");
expect(wrapper.emitted().onZoom[1][0]).toBe(10);
await buttons.at(2).trigger("click");
expect(wrapper.emitted().onZoom[2][0]).toBe(11);
});
});