Files
fredy/test/utils.js

32 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2025-12-11 10:40:55 +01:00
/*
* Copyright (c) 2026 by Christian Kellner.
2025-12-11 10:40:55 +01:00
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
*/
2026-03-16 14:26:58 +01:00
import { vi } from 'vitest';
import { readFile } from 'fs/promises';
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), 'utf-8'),
);
2026-03-16 14:26:58 +01:00
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 }));
/**
* @returns {Promise<typeof import('../lib/FredyPipelineExecutioner.js').default>}
*/
export const mockFredy = async () => {
2026-03-16 14:26:58 +01:00
const mod = await import('../lib/FredyPipelineExecutioner.js');
return mod.default;
};