-
Michael Winberry authored
Update the fortify configuration to retrieve a list of values from the backend. References platform-one/party-bus/valkyrie/valkyrie-api#2
Michael Winberry authoredUpdate the fortify configuration to retrieve a list of values from the backend. References platform-one/party-bus/valkyrie/valkyrie-api#2
MissionAppFortifyConfig.spec.js 1.53 KiB
import Vuex from "vuex";
import Vuetify from "vuetify";
import { mount, createLocalVue } from "@vue/test-utils";
import MissionAppFortifyConfig from "@/components/MissionAppFortifyConfig";
import MissionAppApi from "@/api/services/missionApp";
const localVue = createLocalVue();
const vuetify = new Vuetify();
localVue.use(Vuex);
localVue.use(vuetify);
describe("Mission App Dns Form Section", () => {
let wrapper;
let mockFortifyValue;
beforeEach(() => {
mockFortifyValue = {
name: "Fortify Lanuage Name",
value: "Fortify Language Value",
};
jest
.spyOn(MissionAppApi, "getFortifyValues")
.mockResolvedValue([mockFortifyValue]);
wrapper = mount(MissionAppFortifyConfig, {
localVue,
vuetify,
propsData: {
fortifyConfiguration: {},
},
mocks: {
$store: {},
},
});
});
it("populates the fortify values on create", () => {
expect(MissionAppApi.getFortifyValues).toHaveBeenCalledTimes(1);
});
it("Sets the fortifyConfiguration language", () => {
wrapper.find("input").setValue(mockFortifyValue.value);
expect(wrapper.props().fortifyConfiguration.language).toBe(
mockFortifyValue.value
);
});
it("should handle error", async () => {
wrapper.vm.$store.commit = jest.fn();
console.error = jest.fn();
jest
.spyOn(MissionAppApi, "getFortifyValues")
.mockRejectedValue(new Error("Some Error"));
await wrapper.vm.retrieveFortifyValues();
expect(wrapper.vm.$store.commit).toHaveBeenCalled();
});
});