38 lines
972 B
TypeScript
38 lines
972 B
TypeScript
// __mocks__/api.ts
|
|
|
|
import { language_matrix, language_matrix_entry } from "@/app/i18n/api";
|
|
|
|
// Import the actual API module to extend its functionality
|
|
const origApi = jest.requireActual('@/app/i18n/api.ts');
|
|
|
|
class LanguageServer {
|
|
constructor(...args: any[]) { }
|
|
fetchLanguages(): language_matrix {
|
|
return {
|
|
"en" : { code: "en", name: "English", targets: ['fr', 'es'] },
|
|
"fr" : { code: "fr", name: "French", targets: ["en", "es"] },
|
|
"es": { code: "es", name: "Spanish", targets: ['fr', 'en'] },
|
|
}
|
|
}
|
|
}
|
|
|
|
class Translator {
|
|
constructor(...args : any []) {}
|
|
translate(message : string, target : string) {
|
|
return message;
|
|
}
|
|
}
|
|
|
|
class CachedTranslator extends Translator{
|
|
|
|
}
|
|
|
|
module.exports = {
|
|
...origApi,
|
|
LanguageServer,
|
|
Translator,
|
|
CachedTranslator,
|
|
// Mock the specific functions you want to override
|
|
fetchData: jest.fn(() => Promise.resolve({ data: 'mocked data' })),
|
|
// Add more mock implementations as needed
|
|
}; |