UNCLASSIFIED

Commit 48a609dc authored by Keith Becker's avatar Keith Becker
Browse files

clean up from merge

parent f4727ea6
...@@ -4,7 +4,6 @@ export const availableSeatsInCourse = ( ...@@ -4,7 +4,6 @@ export const availableSeatsInCourse = (
registrations registrations
) => { ) => {
if (!Number.isInteger(capacity)) { if (!Number.isInteger(capacity)) {
console.warn("capacity was not an integer so default course capacity is 0");
return 0; return 0;
} }
if (Array.isArray(selectedMembers)) { if (Array.isArray(selectedMembers)) {
......
...@@ -37,6 +37,11 @@ describe("TrainingDetails", () => { ...@@ -37,6 +37,11 @@ describe("TrainingDetails", () => {
TrainingDetails.fetchData = jest.fn(); TrainingDetails.fetchData = jest.fn();
const wrapper = shallowMount(TrainingDetails, { const wrapper = shallowMount(TrainingDetails, {
mocks: { mocks: {
$route: {
params: {
trainingId: 1,
},
},
$store: { $store: {
state: { state: {
error: {}, error: {},
...@@ -171,92 +176,6 @@ describe("TrainingDetails", () => { ...@@ -171,92 +176,6 @@ describe("TrainingDetails", () => {
true true
); );
}); });
it("should add student", async () => {
TrainingService.getCourse = jest.fn().mockResolvedValue(mockCourse);
TrainingService.getCourseRegistrationsById = jest
.fn()
.mockResolvedValue({ registrations: [] });
TrainingService.addStudents = jest.fn().mockResolvedValue([]);
const wrapper = shallowMount(TrainingDetails, {
mocks: {
$store: {
state: {
error: {},
},
commit: jest.fn(),
},
},
data() {
return {
selectedUsers: [{ userId: 1 }, { userId: 2 }],
listItems: [{ userId: 1 }, { userId: 2 }, { userId: 3 }],
};
},
propsData,
localVue,
vuetify,
});
await flushPromises();
wrapper.vm.$refs.userSelect.clear = jest.fn();
await wrapper.vm.addStudent([{ id: 1 }]);
expect(TrainingService.addStudents).toHaveBeenCalledTimes(1);
});
it("addStudent should catch error", async () => {
console.error = jest.fn(); // mock console.error when expecting error messages
TrainingService.getCourse = jest.fn().mockResolvedValue(mockCourse);
TrainingService.addStudents = jest.fn().mockRejectedValue("error");
const wrapper = shallowMount(TrainingDetails, {
mocks: {
$store: {
state: {
error: {},
},
commit: jest.fn(),
},
},
propsData,
localVue,
vuetify,
});
wrapper.vm.$refs.userSelect.clear = jest.fn();
await wrapper.vm.addStudent();
expect(wrapper.vm.$store.commit).toHaveBeenCalledWith(
SET_ERROR_MESSAGE,
"error"
);
});
it("should cancel add student", async () => {
TrainingService.getCourse = jest.fn().mockResolvedValue(mockCourse);
TrainingService.getCourseRegistrationsById = jest
.fn()
.mockResolvedValue({ registrations: [] });
const wrapper = shallowMount(TrainingDetails, {
mocks: {
$store: {
state: {
error: {},
},
commit: jest.fn(),
},
},
data() {
return {
selectedUsers: [{ userId: 1 }, { userId: 2 }],
listItems: [{ userId: 1 }, { userId: 2 }, { userId: 3 }],
};
},
propsData,
localVue,
vuetify,
});
await flushPromises();
wrapper.vm.$refs.userSelect.clear = jest.fn();
wrapper.vm.cancelAddStudent();
expect(wrapper.vm.$refs.userSelect.clear).toHaveBeenCalledTimes(1);
});
it("should not show error by default", () => { it("should not show error by default", () => {
TrainingService.getCourse = jest.fn().mockResolvedValue(mockCourse); TrainingService.getCourse = jest.fn().mockResolvedValue(mockCourse);
// render the component // render the component
......
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