Refactor films module
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
import { mount, shallowMount } from "@vue/test-utils";
|
||||
import axios from "axios";
|
||||
import FilmsView from "@/pages/films";
|
||||
import mockFilms from "./fake-films.json";
|
||||
|
||||
jest.mock("axios", () => ({
|
||||
$get: jest.fn(() => mockFilms)
|
||||
}));
|
||||
|
||||
describe("Films page", () => {
|
||||
it("should render Films page instance", () => {
|
||||
const wrapper = mount(FilmsView);
|
||||
expect(wrapper.find("img").exists()).toBe(true);
|
||||
});
|
||||
|
||||
it("should get films from Ghibli API", async () => {
|
||||
let wrapper = shallowMount(FilmsView, {
|
||||
mocks: {
|
||||
$axios: axios
|
||||
}
|
||||
});
|
||||
|
||||
expect((await wrapper.vm.$options.asyncData(wrapper.vm)).films).toEqual(
|
||||
mockFilms
|
||||
);
|
||||
|
||||
// Init page with mocked asyncData
|
||||
wrapper = shallowMount(FilmsView, {
|
||||
mocks: {
|
||||
films: (await wrapper.vm.$options.asyncData(wrapper.vm)).films,
|
||||
$axios: axios
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper.findComponent({ name: "Grid" }).exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user