Move store test file to /store folder

This commit is contained in:
2020-12-18 06:19:37 +01:00
parent c416542449
commit 1801fd54ae
2 changed files with 2 additions and 2 deletions

35
store/actions.spec.js Normal file
View File

@@ -0,0 +1,35 @@
import { actions } from "@/store";
import axios from "axios";
import mockFilms from "@/test/fake-films.json";
let url = "";
jest.mock("axios", () => ({
$get: _url => {
return new Promise(resolve => {
url = _url;
resolve(mockFilms);
});
}
}));
describe("Vuex actions.", () => {
it("tests getFilms action.", async () => {
const commit = jest.fn();
actions.$axios = axios;
await actions.getFilms({ commit });
expect(url).toBe("/api/films");
expect(commit).toHaveBeenCalledWith("setFilms", mockFilms);
});
it("catches errors.", async () => {
const commit = jest.fn();
actions.$axios = null;
await expect(actions.getFilms({ commit })).rejects.toThrow(
"API Error occurred."
);
});
});