mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- Fixed test cases
This commit is contained in:
parent
fbd354ebfb
commit
cb1668fd1d
@ -59,7 +59,7 @@ describe('getModelNames', () => {
|
||||
properties: [],
|
||||
});
|
||||
|
||||
expect(getModelNames(new Map<string, Model>())).toEqual([]);
|
||||
expect(getModelNames(models)).toEqual(['Doe', 'Jane', 'John']);
|
||||
expect(getModelNames(new Map<string, Model>())).toEqual(['Dictionary']);
|
||||
expect(getModelNames(models)).toEqual(['Dictionary', 'Doe', 'Jane', 'John']);
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,16 +1,20 @@
|
||||
import { readHandlebarsTemplates } from './readHandlebarsTemplates';
|
||||
import * as fs from 'fs';
|
||||
import { Language } from '../index';
|
||||
import * as glob from 'glob';
|
||||
|
||||
jest.mock('fs');
|
||||
jest.mock('glob');
|
||||
|
||||
const fsExistsSync = fs.existsSync as jest.MockedFunction<typeof fs.existsSync>;
|
||||
const fsReadFileSync = fs.readFileSync as jest.MockedFunction<typeof fs.readFileSync>;
|
||||
const globSync = glob.sync as jest.MockedFunction<typeof glob.sync>;
|
||||
|
||||
describe('readHandlebarsTemplates', () => {
|
||||
it('should read the templates', () => {
|
||||
fsExistsSync.mockReturnValue(true);
|
||||
fsReadFileSync.mockReturnValue('{{{message}}}');
|
||||
globSync.mockReturnValue([]);
|
||||
|
||||
const template = readHandlebarsTemplates(Language.TYPESCRIPT);
|
||||
|
||||
@ -18,8 +22,10 @@ describe('readHandlebarsTemplates', () => {
|
||||
expect(template.index).toBeDefined();
|
||||
expect(template.model).toBeDefined();
|
||||
expect(template.service).toBeDefined();
|
||||
expect(template.settings).toBeDefined();
|
||||
expect(template.index({ message: 'Hello World!' })).toEqual('Hello World!');
|
||||
expect(template.model({ message: 'Hello World!' })).toEqual('Hello World!');
|
||||
expect(template.service({ message: 'Hello World!' })).toEqual('Hello World!');
|
||||
expect(template.settings({ message: 'Hello World!' })).toEqual('Hello World!');
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user