From f1b475b9664505524cd51a7bdb713a34718cf5eb Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Sun, 23 Aug 2020 14:46:36 -0400 Subject: [PATCH] Add test spec for components/graphql/typelink.vue --- components/graphql/__types__/typelink.spec.js | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 components/graphql/__types__/typelink.spec.js 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") + }) +})