mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- Fixed unit tests
This commit is contained in:
parent
30e26621a5
commit
8149bd21c5
@ -5,6 +5,7 @@
|
||||
export function getSortedImports(imports: string[]): string[] {
|
||||
return imports
|
||||
.filter(name => name)
|
||||
.filter(name => name.trim())
|
||||
.filter((name, index, arr) => arr.indexOf(name) === index)
|
||||
.sort((a, b) => {
|
||||
const nameA: string = a.toLowerCase();
|
||||
|
||||
@ -7,14 +7,17 @@ import { Model } from '../client/interfaces/Model';
|
||||
import { Templates } from './readHandlebarsTemplates';
|
||||
import { Service } from '../client/interfaces/Service';
|
||||
import { Language } from '../index';
|
||||
import * as glob from 'glob';
|
||||
|
||||
jest.mock('rimraf');
|
||||
jest.mock('mkdirp');
|
||||
jest.mock('fs');
|
||||
jest.mock('glob');
|
||||
|
||||
const rimrafSync = mkdirp.sync as jest.MockedFunction<typeof mkdirp.sync>;
|
||||
const mkdirpSync = rimraf.sync as jest.MockedFunction<typeof rimraf.sync>;
|
||||
const fsWriteFileSync = fs.writeFileSync as jest.MockedFunction<typeof fs.writeFileSync>;
|
||||
const globSync = glob.sync as jest.MockedFunction<typeof glob.sync>;
|
||||
|
||||
describe('writeClient', () => {
|
||||
it('should write to filesystem', () => {
|
||||
@ -31,10 +34,13 @@ describe('writeClient', () => {
|
||||
service: () => 'dummy',
|
||||
};
|
||||
|
||||
globSync.mockReturnValue([]);
|
||||
|
||||
writeClient(client, Language.TYPESCRIPT, templates, '/');
|
||||
|
||||
expect(rimrafSync).toBeCalled();
|
||||
expect(mkdirpSync).toBeCalled();
|
||||
expect(fsWriteFileSync).toBeCalled();
|
||||
expect(globSync).toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user