openapi-typescript-codegen/src/utils/readHandlebarsTemplate.spec.ts
2019-11-05 10:39:26 +01:00

20 lines
655 B
TypeScript

import { readHandlebarsTemplate } from './readHandlebarsTemplate';
import * as fs from 'fs';
jest.mock('fs');
const fsExistsSync = fs.existsSync as jest.MockedFunction<typeof fs.existsSync>;
const fsReadFileSync = fs.readFileSync as jest.MockedFunction<typeof fs.readFileSync>;
describe('readHandlebarsTemplate', () => {
it('should read the template', () => {
fsExistsSync.mockReturnValue(true);
fsReadFileSync.mockReturnValue('{{{message}}}');
const template = readHandlebarsTemplate('/');
expect(template).toBeDefined();
expect(template({ message: 'Hello World!' })).toEqual('Hello World!');
});
});