Setup routing for FruitDetails + fetch data on route transition + Fix fruit tests

This commit is contained in:
2020-12-04 03:25:59 +01:00
parent d2b7c4d93c
commit a62d07e97e
13 changed files with 581 additions and 79 deletions

View File

@@ -1,4 +1,4 @@
import { mount } from "@vue/test-utils";
import { mount, RouterLinkStub } from "@vue/test-utils";
// import axios from "axios";
import store from "@/store/index.js";
import Fruits from "@/views/Fruits.vue";
@@ -10,9 +10,9 @@ import Fruits from "@/views/Fruits.vue";
describe("Test Fruits page.", () => {
it("dispatches getFruits on mounted", async () => {
// axios.get.mockImplementationOnce(() => Promise.resolve({ data: { data: "value" } }));
const wrapper = mount(Fruits, { store });
const wrapper = mount(Fruits, { store, stubs: { RouterLink: RouterLinkStub } });
await store.dispatch("getFruits");
expect(store.state.fruits.fruitCount).toBe(6);
expect(store.state.fruits.length).toBe(7);
});
});