Add unit tests on Login component

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-04-16 14:49:43 +02:00
parent f2175c6498
commit 77200ea587
7 changed files with 295 additions and 53 deletions

View File

@@ -2,23 +2,45 @@ import { config, createLocalVue, mount } from "@vue/test-utils";
import { routes } from "@/router";
import App from "@/App.vue";
import VueRouter from "vue-router";
import Home from "@/views/Home.vue";
import Buefy from "buefy";
const localVue = createLocalVue();
config.mocks.$t = (key: string): string => key;
localVue.use(VueRouter);
const router = new VueRouter({ routes });
const wrapper = mount(App, {
localVue,
router,
stubs: ["NavBar", "mobilizon-footer"],
});
localVue.use(Buefy);
describe("routing", () => {
test("Homepage", async () => {
router.push("/");
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");
await wrapper.vm.$nextTick();
expect(wrapper.findComponent(Home).exists()).toBe(true);
await wrapper.vm.$nextTick();
expect(wrapper.vm.$route.path).toBe("/about/instance");
expect(wrapper.html()).toContain(
'<a href="/about/instance" aria-current="page"'
);
});
});