- Fixed test cases

This commit is contained in:
Ferdi Koomen 2019-11-22 23:01:47 +01:00
parent fbd354ebfb
commit cb1668fd1d
2 changed files with 8 additions and 2 deletions

View File

@ -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']);
});
});

View File

@ -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!');
});
});