UNCLASSIFIED

Commit 829b8733 authored by Graham Smith's avatar Graham Smith
Browse files

more tests

parent 86833a34
import { shallowMount } from "@vue/test-utils";
import Launchboard from "@/views/Launchboard.vue";
import UserService from "@/api/services/user";
import flushPromises from "flush-promises";
describe("Launchboard", () => {
it("should get user and toggle loading state", async () => {
UserService.getUser = jest.fn().mockResolvedValue({ name: "mock" });
const wrapper = shallowMount(Launchboard);
expect(wrapper.vm.loading.user).toBe(true);
await flushPromises();
expect(UserService.getUser).toHaveBeenCalledTimes(1);
expect(wrapper.vm.loading.user).toBe(false);
});
it("should toggle loading state on error", async () => {
UserService.getUser = jest.fn().mockRejectedValue("mock error");
const wrapper = shallowMount(Launchboard);
expect(wrapper.vm.loading.user).toBe(true);
await flushPromises();
expect(UserService.getUser).toHaveBeenCalledTimes(1);
expect(wrapper.vm.loading.user).toBe(false);
});
it("should compute newUser value", async () => {
UserService.getUser = jest.fn().mockResolvedValue({ name: "mock" });
const wrapper = shallowMount(Launchboard);
await flushPromises();
wrapper.vm.user = {
auth: {
newUser: true
}
};
expect(wrapper.vm.newUser).toBe(true);
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment