mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import type { Service } from '../client/interfaces/Service';
|
|
import { HttpClient } from '../HttpClient';
|
|
import { Indent } from '../Indent';
|
|
import { writeFile } from './fileSystem';
|
|
import { Templates } from './registerHandlebarTemplates';
|
|
import { writeClientServices } from './writeClientServices';
|
|
|
|
jest.mock('./fileSystem');
|
|
|
|
describe('writeClientServices', () => {
|
|
it('should write to filesystem', async () => {
|
|
const services: Service[] = [
|
|
{
|
|
name: 'User',
|
|
operations: [],
|
|
imports: [],
|
|
},
|
|
];
|
|
|
|
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 writeClientServices(services, templates, '/', HttpClient.FETCH, false, false, Indent.SPACE_4, 'Service');
|
|
|
|
expect(writeFile).toBeCalledWith('/UserService.ts', 'service');
|
|
});
|
|
});
|