diff --git a/components/graphql/__types__/typelink.spec.js b/components/graphql/__types__/typelink.spec.js new file mode 100644 index 000000000..0a3a60885 --- /dev/null +++ b/components/graphql/__types__/typelink.spec.js @@ -0,0 +1,44 @@ +import typelink from "../typelink" +import { shallowMount } from "@vue/test-utils" + +const factory = (props) => + shallowMount(typelink, { + propsData: props, + }) + +const gqlType = { + toString: () => "TestType", +} + +describe("typelink", () => { + test("mounts properly when valid props are given", () => { + const wrapper = factory({ + gqlType, + jumpTypeCallback: jest.fn(), + }) + + expect(wrapper).toBeTruthy() + }) + + test("jumpToTypeCallback is called when the link is clicked", async () => { + const callback = jest.fn() + + const wrapper = factory({ + gqlType, + jumpTypeCallback: callback, + }) + + await wrapper.trigger("click") + + expect(callback).toHaveBeenCalledTimes(1) + }) + + test("link text is the type string", () => { + const wrapper = factory({ + gqlType, + jumpTypeCallback: jest.fn(), + }) + + expect(wrapper.text()).toBe("TestType") + }) +})