import { beforeEach, describe, it, expect } from "vitest"; import { enUS } from "date-fns/locale"; import { routes } from "@/router"; import { createRouter, createWebHistory, Router } from "vue-router"; import { config, shallowMount } from "@vue/test-utils"; import { Oruga } from "@oruga-ui/oruga-next"; import flushPromises from "flush-promises"; import { getMockClient, requestHandlers } from "../../mocks/client"; import { htmlRemoveId } from "../../common"; import MaterialIcon from "@/components/core/MaterialIcon.vue"; config.global.plugins.push(Oruga); let router: Router; beforeEach(async () => { router = createRouter({ history: createWebHistory(), routes: routes, }); // await router.isReady(); }); const generateWrapper = (iconname: string) => { const global_data = getMockClient([]); global_data.provide.dateFnsLocale = enUS; global_data.plugins = [router]; return shallowMount(MaterialIcon, { props: { icon: ["", iconname], }, global: { ...global_data, stubs: { RouterLink: false, }, }, }); }; describe("MaterialIcon", () => { it("Show GoogleHangouts", async () => { const wrapper = generateWrapper("GoogleHangouts"); await wrapper.vm.$nextTick(); await flushPromises(); expect(htmlRemoveId(wrapper.html())).toMatchSnapshot(); }); it("Show CalendarStar", async () => { const wrapper = generateWrapper("CalendarStar"); await wrapper.vm.$nextTick(); await flushPromises(); expect(htmlRemoveId(wrapper.html())).toMatchSnapshot(); }); it("Show account-multiple-plus", async () => { const wrapper = generateWrapper("account-multiple-plus"); await wrapper.vm.$nextTick(); await flushPromises(); expect(htmlRemoveId(wrapper.html())).toMatchSnapshot(); }); });