mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import type { Client } from '../client/interfaces/Client';
|
|
import { HttpClient } from '../HttpClient';
|
|
import { Indent } from '../Indent';
|
|
import { writeFile } from './fileSystem';
|
|
import type { Templates } from './registerHandlebarTemplates';
|
|
import { writeClientClass } from './writeClientClass';
|
|
|
|
jest.mock('./fileSystem');
|
|
|
|
describe('writeClientClass', () => {
|
|
it('should write to filesystem', async () => {
|
|
const client: Client = {
|
|
server: 'http://localhost:8080',
|
|
version: 'v1',
|
|
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 writeClientClass(client, templates, './dist', HttpClient.FETCH, 'AppClient', Indent.SPACE_4, '');
|
|
|
|
expect(writeFile).toBeCalled();
|
|
});
|
|
});
|