Generate question bank domain model from JDL

This commit is contained in:
jieun committed 2026-10-20 18:46:29 +09:00
1 parent 1d97cc4e31
commit 1d74d8f04b
160 files changed
+26900 -2

No files matched your search

@@ -0,0 +1,103 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { type MountingOptions, shallowMount } from '@vue/test-utils';
import AlertService from '@/shared/alert/alert.service';
import ExamAnswer from './exam-answer.vue';
type ExamAnswerComponentType = InstanceType<typeof ExamAnswer>;
const bModalStub = {
render: () => {},
methods: {
hide: () => {},
show: () => {},
},
};
describe('Component Tests', () => {
let alertService: AlertService;
describe('ExamAnswer Management Component', () => {
let examAnswerServiceStub: any;
let mountOptions: MountingOptions<ExamAnswerComponentType>['global'];
beforeEach(() => {
examAnswerServiceStub = {
retrieve: vi.fn(),
delete: vi.fn(),
};
examAnswerServiceStub.retrieve.mockResolvedValue({ headers: {} });
alertService = new AlertService({
i18n: { t: vi.fn() } as any,
toast: {
create: vi.fn(),
} as any,
});
mountOptions = {
stubs: {
bModal: bModalStub as any,
'font-awesome-icon': true,
'b-badge': true,
'b-button': true,
'router-link': true,
},
directives: {
'b-modal': {},
},
provide: {
alertService,
examAnswerService: () => examAnswerServiceStub,
},
};
});
describe('Mount', () => {
it('Should call load all on init', async () => {
// GIVEN
examAnswerServiceStub.retrieve.mockResolvedValue({ headers: {}, data: [{ id: 123 }] });
// WHEN
const wrapper = shallowMount(ExamAnswer, { global: mountOptions });
const comp = wrapper.vm;
await comp.$nextTick();
// THEN
expect(examAnswerServiceStub.retrieve).toHaveBeenCalledOnce();
expect(comp.examAnswers[0]).toEqual(expect.objectContaining({ id: 123 }));
});
});
describe('Handles', () => {
let comp: ExamAnswerComponentType;
beforeEach(async () => {
const wrapper = shallowMount(ExamAnswer, { global: mountOptions });
comp = wrapper.vm;
await comp.$nextTick();
examAnswerServiceStub.retrieve.mockReset();
examAnswerServiceStub.retrieve.mockResolvedValue({ headers: {}, data: [] });
});
it('Should call delete service on confirmDelete', async () => {
// GIVEN
examAnswerServiceStub.delete.mockResolvedValue({});
// WHEN
comp.prepareRemove({ id: 123 });
comp.removeExamAnswer();
await comp.$nextTick(); // clear components
// THEN
expect(examAnswerServiceStub.delete).toHaveBeenCalled();
// THEN
await comp.$nextTick(); // handle component clear watch
expect(examAnswerServiceStub.retrieve).toHaveBeenCalledTimes(1);
});
});
});
});