mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
20 lines
655 B
TypeScript
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!');
|
|
});
|
|
});
|