mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
25 lines
962 B
TypeScript
25 lines
962 B
TypeScript
import { EjsTemplateEngine } from '../../../../src/util/templates/EjsTemplateEngine';
|
|
|
|
jest.mock('../../../../src/util/templates/TemplateEngine', (): any => ({
|
|
getTemplateFilePath: jest.fn((): string => `filename`),
|
|
readTemplate: jest.fn(async({ templateString }): Promise<string> => `${templateString}: <%= detail %>`),
|
|
}));
|
|
|
|
describe('A EjsTemplateEngine', (): void => {
|
|
const defaultTemplate = { templateString: 'xyz' };
|
|
const contents = { detail: 'a&b' };
|
|
let templateEngine: EjsTemplateEngine;
|
|
|
|
beforeEach((): void => {
|
|
templateEngine = new EjsTemplateEngine(defaultTemplate);
|
|
});
|
|
|
|
it('uses the default template when no template was passed.', async(): Promise<void> => {
|
|
await expect(templateEngine.render(contents)).resolves.toBe('xyz: a&b');
|
|
});
|
|
|
|
it('uses the passed template.', async(): Promise<void> => {
|
|
await expect(templateEngine.render(contents, { templateString: 'my' })).resolves.toBe('my: a&b');
|
|
});
|
|
});
|