|
|
@@ -4,16 +4,20 @@ import type Crowi from '~/server/crowi';
|
|
|
|
|
|
import { ImportService } from './import';
|
|
|
|
|
|
+
|
|
|
const mocks = vi.hoisted(() => {
|
|
|
return {
|
|
|
+ constructConvertMapMock: vi.fn(),
|
|
|
setupIndependentModelsMock: vi.fn(),
|
|
|
- testMock: vi.fn(),
|
|
|
};
|
|
|
});
|
|
|
|
|
|
vi.mock('~/server/crowi/setup-models', () => ({
|
|
|
setupIndependentModels: mocks.setupIndependentModelsMock,
|
|
|
}));
|
|
|
+vi.mock('./construct-convert-map', () => ({
|
|
|
+ constructConvertMap: mocks.constructConvertMapMock,
|
|
|
+}));
|
|
|
|
|
|
describe('ImportService', () => {
|
|
|
|
|
|
@@ -32,11 +36,17 @@ describe('ImportService', () => {
|
|
|
|
|
|
describe('preImport', () => {
|
|
|
test('should call setupIndependentModels', async() => {
|
|
|
+ // arrange
|
|
|
+ const convertMapMock = mock();
|
|
|
+ mocks.constructConvertMapMock.mockImplementation(() => convertMapMock);
|
|
|
+
|
|
|
// act
|
|
|
await importService.preImport();
|
|
|
|
|
|
// assert
|
|
|
expect(mocks.setupIndependentModelsMock).toHaveBeenCalledOnce();
|
|
|
+ expect(mocks.constructConvertMapMock).toHaveBeenCalledOnce();
|
|
|
+ expect(importService.convertMap).toStrictEqual(convertMapMock);
|
|
|
});
|
|
|
});
|
|
|
});
|