import { readHandlebarsTemplate } from './readHandlebarsTemplate'; import * as fs from 'fs'; jest.mock('fs'); const fsExistsSync = fs.existsSync as jest.MockedFunction; const fsReadFileSync = fs.readFileSync as jest.MockedFunction; 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!'); }); });