mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
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.'
26 lines
821 B
JavaScript
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);
|
|
});
|
|
});
|