12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- import { mount } from "@vue/test-utils"
- import tab from "../Tab"
- const factory = (props, data) => {
- if (data) {
- return mount(tab, {
- propsData: props,
- data: () => data,
- slots: {
- default: '<div id="testdiv"></div>',
- },
- })
- } else {
- return mount(tab, {
- propsData: props,
- slots: {
- default: '<div id="testdiv"></div>',
- },
- })
- }
- }
- describe("tab", () => {
- test("mounts properly when needed props are passed in", () => {
- const wrapper = factory({
- label: "TestLabel",
- icon: "TestIcon",
- id: "testid",
- selected: true,
- })
- expect(wrapper).toBeTruthy()
- })
- test("mounts properly when selected prop is not passed", () => {
- const wrapper = factory({
- label: "TestLabel",
- icon: "TestIcon",
- id: "testid",
- })
- expect(wrapper).toBeTruthy()
- })
- test("if 'selected' prop is not passed, it is set to false by default", () => {
- const wrapper = factory({
- label: "TestLabel",
- icon: "TestIcon",
- id: "testid",
- })
- expect(wrapper.props("selected")).toEqual(false)
- })
- test("if set active, the slot is shown", () => {
- const wrapper = factory(
- {
- label: "TestLabel",
- icon: "TestIcon",
- id: "testid",
- selected: true,
- },
- {
- active: true,
- }
- )
- expect(wrapper.find("#testdiv").isVisible()).toEqual(true)
- })
- test("if not set active, the slot is not rendered", () => {
- const wrapper = factory(
- {
- label: "TestLabel",
- icon: "TestIcon",
- id: "testid",
- },
- {
- active: false,
- }
- )
- expect(wrapper.find("#testdiv").isVisible()).toEqual(false)
- })
- })
|