mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
moving from jest to vitest
This commit is contained in:
@@ -3,29 +3,24 @@
|
||||
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
|
||||
*/
|
||||
|
||||
import { vi } from 'vitest';
|
||||
import { readFile } from 'fs/promises';
|
||||
import esmock from 'esmock';
|
||||
import * as mockStore from './mocks/mockStore.js';
|
||||
import { send } from './mocks/mockNotification.js';
|
||||
|
||||
export const providerConfig = JSON.parse(await readFile(new URL('./provider/testProvider.json', import.meta.url)));
|
||||
|
||||
vi.mock('../lib/services/storage/listingsStorage.js', () => mockStore);
|
||||
vi.mock('../lib/services/storage/settingsStorage.js', () => mockStore);
|
||||
vi.mock('../lib/services/geocoding/geoCodingService.js', () => ({
|
||||
geocodeAddress: mockStore.getGeocoordinatesByAddress,
|
||||
}));
|
||||
vi.mock('../lib/services/storage/jobStorage.js', () => ({
|
||||
getJob: (jobKey) => ({ id: jobKey, userId: 'user1' }),
|
||||
}));
|
||||
vi.mock('../lib/notification/notify.js', () => ({ send }));
|
||||
|
||||
export const mockFredy = async () => {
|
||||
return await esmock('../lib/FredyPipelineExecutioner', {
|
||||
'../lib/services/storage/listingsStorage.js': {
|
||||
...mockStore,
|
||||
},
|
||||
'../lib/services/storage/settingsStorage.js': {
|
||||
...mockStore,
|
||||
},
|
||||
'../lib/services/geocoding/geoCodingService.js': {
|
||||
geocodeAddress: mockStore.getGeocoordinatesByAddress,
|
||||
},
|
||||
'../lib/services/storage/jobStorage.js': {
|
||||
getJob: (jobKey) => ({ id: jobKey, userId: 'user1' }),
|
||||
},
|
||||
'../lib/notification/notify.js': {
|
||||
send,
|
||||
},
|
||||
});
|
||||
const mod = await import('../lib/FredyPipelineExecutioner.js');
|
||||
return mod.default ?? mod;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user