mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import type { Client } from '../client/interfaces/Client';
|
|
import { writeFile } from './fileSystem';
|
|
import type { Templates } from './registerHandlebarTemplates';
|
|
import { writeClientIndex } from './writeClientIndex';
|
|
|
|
jest.mock('./fileSystem');
|
|
|
|
describe('writeClientIndex', () => {
|
|
it('should write to filesystem', async () => {
|
|
const client: Client = {
|
|
server: 'http://localhost:8080',
|
|
version: '1.0',
|
|
models: [],
|
|
services: [],
|
|
};
|
|
|
|
const templates: Templates = {
|
|
index: () => 'index',
|
|
client: () => 'client',
|
|
exports: {
|
|
model: () => 'model',
|
|
schema: () => 'schema',
|
|
service: () => 'service',
|
|
},
|
|
core: {
|
|
settings: () => 'settings',
|
|
apiError: () => 'apiError',
|
|
apiRequestOptions: () => 'apiRequestOptions',
|
|
apiResult: () => 'apiResult',
|
|
cancelablePromise: () => 'cancelablePromise',
|
|
request: () => 'request',
|
|
baseHttpRequest: () => 'baseHttpRequest',
|
|
httpRequest: () => 'httpRequest',
|
|
},
|
|
};
|
|
|
|
await writeClientIndex(client, templates, '/', true, true, true, true, true, 'Service', '');
|
|
|
|
expect(writeFile).toBeCalledWith('/index.ts', 'index');
|
|
});
|
|
});
|