Skip to content

Commit 8149bd2

Browse files
committed
- Fixed unit tests
1 parent 30e2662 commit 8149bd2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/utils/getSortedImports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
export function getSortedImports(imports: string[]): string[] {
66
return imports
77
.filter(name => name)
8+
.filter(name => name.trim())
89
.filter((name, index, arr) => arr.indexOf(name) === index)
910
.sort((a, b) => {
1011
const nameA: string = a.toLowerCase();

src/utils/writeClient.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import { Model } from '../client/interfaces/Model';
77
import { Templates } from './readHandlebarsTemplates';
88
import { Service } from '../client/interfaces/Service';
99
import { Language } from '../index';
10+
import * as glob from 'glob';
1011

1112
jest.mock('rimraf');
1213
jest.mock('mkdirp');
1314
jest.mock('fs');
15+
jest.mock('glob');
1416

1517
const rimrafSync = mkdirp.sync as jest.MockedFunction<typeof mkdirp.sync>;
1618
const mkdirpSync = rimraf.sync as jest.MockedFunction<typeof rimraf.sync>;
1719
const fsWriteFileSync = fs.writeFileSync as jest.MockedFunction<typeof fs.writeFileSync>;
20+
const globSync = glob.sync as jest.MockedFunction<typeof glob.sync>;
1821

1922
describe('writeClient', () => {
2023
it('should write to filesystem', () => {
@@ -31,10 +34,13 @@ describe('writeClient', () => {
3134
service: () => 'dummy',
3235
};
3336

37+
globSync.mockReturnValue([]);
38+
3439
writeClient(client, Language.TYPESCRIPT, templates, '/');
3540

3641
expect(rimrafSync).toBeCalled();
3742
expect(mkdirpSync).toBeCalled();
3843
expect(fsWriteFileSync).toBeCalled();
44+
expect(globSync).toBeCalled();
3945
});
4046
});

0 commit comments

Comments
 (0)