2020-12-02 11:19:39 +01:00
|
|
|
import { config, createLocalVue, mount } from "@vue/test-utils";
|
|
|
|
import { routes } from "@/router";
|
|
|
|
import App from "@/App.vue";
|
|
|
|
import VueRouter from "vue-router";
|
2021-04-16 14:49:43 +02:00
|
|
|
import Buefy from "buefy";
|
2021-09-07 17:52:34 +02:00
|
|
|
import flushPromises from "flush-promises";
|
2021-10-11 18:29:01 +02:00
|
|
|
import VueAnnouncer from "@vue-a11y/announcer";
|
|
|
|
import VueSkipTo from "@vue-a11y/skip-to";
|
2020-12-02 11:19:39 +01:00
|
|
|
|
|
|
|
const localVue = createLocalVue();
|
|
|
|
config.mocks.$t = (key: string): string => key;
|
|
|
|
localVue.use(VueRouter);
|
2021-04-16 14:49:43 +02:00
|
|
|
localVue.use(Buefy);
|
2021-10-11 18:29:01 +02:00
|
|
|
localVue.use(VueAnnouncer);
|
|
|
|
localVue.use(VueSkipTo);
|
2020-12-02 11:19:39 +01:00
|
|
|
|
|
|
|
describe("routing", () => {
|
|
|
|
test("Homepage", async () => {
|
2021-04-16 14:49:43 +02:00
|
|
|
const router = new VueRouter({ routes, mode: "history" });
|
|
|
|
const wrapper = mount(App, {
|
|
|
|
localVue,
|
|
|
|
router,
|
|
|
|
stubs: {
|
|
|
|
NavBar: true,
|
|
|
|
"mobilizon-footer": true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper.html()).toContain('<div id="homepage">');
|
|
|
|
});
|
|
|
|
|
|
|
|
test("About", async () => {
|
|
|
|
const router = new VueRouter({ routes, mode: "history" });
|
|
|
|
const wrapper = mount(App, {
|
|
|
|
localVue,
|
|
|
|
router,
|
|
|
|
stubs: {
|
|
|
|
NavBar: true,
|
|
|
|
"mobilizon-footer": true,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
router.push("/about");
|
2021-09-07 17:52:34 +02:00
|
|
|
await flushPromises();
|
2021-04-16 14:49:43 +02:00
|
|
|
expect(wrapper.vm.$route.path).toBe("/about/instance");
|
|
|
|
expect(wrapper.html()).toContain(
|
|
|
|
'<a href="/about/instance" aria-current="page"'
|
|
|
|
);
|
2020-12-02 11:19:39 +01:00
|
|
|
});
|
|
|
|
});
|