update frontend lib : remove histoire (obselete) + update vitest - #1815
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
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, mount } from "@vue/test-utils";
|
||||
import { Oruga } from "@oruga-ui/oruga-next";
|
||||
import flushPromises from "flush-promises";
|
||||
import { getMockClient } from "../../mocks/client";
|
||||
import { htmlRemoveId } from "../../common";
|
||||
import InstanceContactLink from "@/components/About/InstanceContactLink.vue";
|
||||
|
||||
config.global.plugins.push(Oruga);
|
||||
|
||||
let router: Router;
|
||||
|
||||
beforeEach(async () => {
|
||||
router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: routes,
|
||||
});
|
||||
|
||||
// await router.isReady();
|
||||
});
|
||||
|
||||
const generateWrapper = (props: any = {}) => {
|
||||
const global_data = getMockClient([]);
|
||||
global_data.provide.dateFnsLocale = enUS;
|
||||
global_data.plugins = [router];
|
||||
return mount(InstanceContactLink, {
|
||||
props: props,
|
||||
global: {
|
||||
...global_data,
|
||||
stubs: {
|
||||
RouterLink: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
describe("InstanceContactLink", () => {
|
||||
it("Show empty", async () => {
|
||||
const wrapper = generateWrapper();
|
||||
await wrapper.vm.$nextTick();
|
||||
await flushPromises();
|
||||
expect(htmlRemoveId(wrapper.html())).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Show string", async () => {
|
||||
const wrapper = generateWrapper({
|
||||
contact: "someone",
|
||||
});
|
||||
await wrapper.vm.$nextTick();
|
||||
await flushPromises();
|
||||
expect(htmlRemoveId(wrapper.html())).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Show email", async () => {
|
||||
const wrapper = generateWrapper({
|
||||
contact: "someone@somewhere.tld",
|
||||
});
|
||||
await wrapper.vm.$nextTick();
|
||||
await flushPromises();
|
||||
expect(htmlRemoveId(wrapper.html())).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Show url", async () => {
|
||||
const wrapper = generateWrapper({
|
||||
contact: "https://somewhere.com",
|
||||
});
|
||||
await wrapper.vm.$nextTick();
|
||||
await flushPromises();
|
||||
expect(htmlRemoveId(wrapper.html())).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`InstanceContactLink > Show email 1`] = `"<p><a dir="auto" title="someone@somewhere.tld" href="mailto:someone@somewhere.tld">someone@somewhere.tld</a></p>"`;
|
||||
|
||||
exports[`InstanceContactLink > Show empty 1`] = `"<p><span>contact uninformed</span></p>"`;
|
||||
|
||||
exports[`InstanceContactLink > Show string 1`] = `"<p><span dir="auto">someone</span></p>"`;
|
||||
|
||||
exports[`InstanceContactLink > Show url 1`] = `"<p><a dir="auto" title="https://somewhere.com" href="https://somewhere.com">somewhere.com</a></p>"`;
|
||||
Reference in New Issue
Block a user