forked from ferdikoomen/openapi-typescript-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwriteClientServices.spec.ts
56 lines (50 loc) · 1.64 KB
/
writeClientServices.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { EOL } from 'os';
import type { Service } from '../client/interfaces/Service';
import { HttpClient } from '../HttpClient';
import { Indent } from '../Indent';
import { writeFile } from './fileSystem';
import type { 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,
false,
Indent.SPACE_4,
'Service'
);
expect(writeFile).toBeCalledWith('/UserService.ts', `service${EOL}`);
});
});