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,91 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { type RouteLocation } from 'vue-router';
import { type MountingOptions, shallowMount } from '@vue/test-utils';
import AlertService from '@/shared/alert/alert.service';
import QuestionDetails from './question-details.vue';
type QuestionDetailsComponentType = InstanceType<typeof QuestionDetails>;
let route: Partial<RouteLocation>;
const routerGoMock = vi.fn();
vi.mock('vue-router', () => ({
useRoute: () => route,
useRouter: () => ({ go: routerGoMock }),
}));
const questionSample = { id: 123 };
describe('Component Tests', () => {
let alertService: AlertService;
afterEach(() => {
vi.resetAllMocks();
});
describe('Question Management Detail Component', () => {
let questionServiceStub: any;
let mountOptions: MountingOptions<QuestionDetailsComponentType>['global'];
beforeEach(() => {
route = {};
questionServiceStub = {
find: vi.fn(),
};
alertService = new AlertService({
i18n: { t: vi.fn() } as any,
toast: {
create: vi.fn(),
} as any,
});
mountOptions = {
stubs: {
'font-awesome-icon': true,
'router-link': true,
},
provide: {
alertService,
questionService: () => questionServiceStub,
},
};
});
describe('Navigate to details', () => {
it('Should call load all on init', async () => {
// GIVEN
questionServiceStub.find.mockResolvedValue(questionSample);
route = {
params: {
questionId: `${123}`,
},
};
const wrapper = shallowMount(QuestionDetails, { global: mountOptions });
const comp = wrapper.vm;
// WHEN
await comp.$nextTick();
// THEN
expect(comp.question).toMatchObject(questionSample);
});
});
describe('Previous state', () => {
it('Should go previous state', async () => {
questionServiceStub.find.mockResolvedValue(questionSample);
const wrapper = shallowMount(QuestionDetails, { global: mountOptions });
const comp = wrapper.vm;
await comp.$nextTick();
comp.previousState();
await comp.$nextTick();
expect(routerGoMock).toHaveBeenCalledWith(-1);
});
});
});
});