mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
Updated file system tests to be OS-agnostic
- Test results for write operations are now designed to match irrespective of the system's path encoding: The previously used UNIX-style path strings do not match on Windows systems. Therefore, expected paths are now being resolved as they are in their corresponding write function. - Unit tests should now pass on all systems.
This commit is contained in:
parent
e0596a22a0
commit
d97edce979
@ -1,4 +1,5 @@
|
||||
import { EOL } from 'os';
|
||||
import { resolve } from 'path';
|
||||
|
||||
import type { Client } from '../client/interfaces/Client';
|
||||
import { HttpClient } from '../HttpClient';
|
||||
@ -40,11 +41,11 @@ describe('writeClientCore', () => {
|
||||
|
||||
await writeClientCore(client, templates, '/', HttpClient.FETCH, Indent.SPACE_4);
|
||||
|
||||
expect(writeFile).toBeCalledWith('/OpenAPI.ts', `settings${EOL}`);
|
||||
expect(writeFile).toBeCalledWith('/ApiError.ts', `apiError${EOL}`);
|
||||
expect(writeFile).toBeCalledWith('/ApiRequestOptions.ts', `apiRequestOptions${EOL}`);
|
||||
expect(writeFile).toBeCalledWith('/ApiResult.ts', `apiResult${EOL}`);
|
||||
expect(writeFile).toBeCalledWith('/CancelablePromise.ts', `cancelablePromise${EOL}`);
|
||||
expect(writeFile).toBeCalledWith('/request.ts', `request${EOL}`);
|
||||
expect(writeFile).toBeCalledWith(resolve('/', '/OpenAPI.ts'), `settings${EOL}`);
|
||||
expect(writeFile).toBeCalledWith(resolve('/', '/ApiError.ts'), `apiError${EOL}`);
|
||||
expect(writeFile).toBeCalledWith(resolve('/', '/ApiRequestOptions.ts'), `apiRequestOptions${EOL}`);
|
||||
expect(writeFile).toBeCalledWith(resolve('/', '/ApiResult.ts'), `apiResult${EOL}`);
|
||||
expect(writeFile).toBeCalledWith(resolve('/', '/CancelablePromise.ts'), `cancelablePromise${EOL}`);
|
||||
expect(writeFile).toBeCalledWith(resolve('/', '/request.ts'), `request${EOL}`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { resolve } from 'path';
|
||||
|
||||
import type { Client } from '../client/interfaces/Client';
|
||||
import { writeFile } from './fileSystem';
|
||||
import type { Templates } from './registerHandlebarTemplates';
|
||||
@ -36,6 +38,6 @@ describe('writeClientIndex', () => {
|
||||
|
||||
await writeClientIndex(client, templates, '/', true, true, true, true, true, 'Service', '');
|
||||
|
||||
expect(writeFile).toBeCalledWith('/index.ts', 'index');
|
||||
expect(writeFile).toBeCalledWith(resolve('/', '/index.ts'), 'index');
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { EOL } from 'os';
|
||||
import { resolve } from 'path';
|
||||
|
||||
import type { Model } from '../client/interfaces/Model';
|
||||
import { HttpClient } from '../HttpClient';
|
||||
@ -53,6 +54,6 @@ describe('writeClientModels', () => {
|
||||
|
||||
await writeClientModels(models, templates, '/', HttpClient.FETCH, false, Indent.SPACE_4);
|
||||
|
||||
expect(writeFile).toBeCalledWith('/User.ts', `model${EOL}`);
|
||||
expect(writeFile).toBeCalledWith(resolve('/', '/User.ts'), `model${EOL}`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { EOL } from 'os';
|
||||
import { resolve } from 'path';
|
||||
|
||||
import type { Model } from '../client/interfaces/Model';
|
||||
import { HttpClient } from '../HttpClient';
|
||||
@ -53,6 +54,6 @@ describe('writeClientSchemas', () => {
|
||||
|
||||
await writeClientSchemas(models, templates, '/', HttpClient.FETCH, false, Indent.SPACE_4);
|
||||
|
||||
expect(writeFile).toBeCalledWith('/$User.ts', `schema${EOL}`);
|
||||
expect(writeFile).toBeCalledWith(resolve('/', '/$User.ts'), `schema${EOL}`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { EOL } from 'os';
|
||||
import { resolve } from 'path';
|
||||
|
||||
import type { Service } from '../client/interfaces/Service';
|
||||
import { HttpClient } from '../HttpClient';
|
||||
@ -41,6 +42,6 @@ describe('writeClientServices', () => {
|
||||
|
||||
await writeClientServices(services, templates, '/', HttpClient.FETCH, false, false, Indent.SPACE_4, 'Service');
|
||||
|
||||
expect(writeFile).toBeCalledWith('/UserService.ts', `service${EOL}`);
|
||||
expect(writeFile).toBeCalledWith(resolve('/', '/UserService.ts'), `service${EOL}`);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user