mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00

* feat: rootpath for static assets and links1 * fix: static asset handler respects root path * fix: use rootPath for links * tests: fix the tests after adding consuctor params * feat: change matchregex instead of stored URLs * feat: baseUrl for handlebar engine and templates * feat: full baseUrl passed to templates * test: fix integration tests + templates * chore: implement requested changes * docs: Describe TemplateEngine interface changes Co-authored-by: Joachim Van Herwegen <joachimvh@gmail.com>
24 lines
948 B
TypeScript
24 lines
948 B
TypeScript
import { HandlebarsTemplateEngine } from '../../../../src/util/templates/HandlebarsTemplateEngine';
|
|
|
|
jest.mock('../../../../src/util/templates/TemplateEngine', (): any => ({
|
|
readTemplate: jest.fn(async({ templateString }): Promise<string> => `${templateString}: {{detail}}`),
|
|
}));
|
|
|
|
describe('A HandlebarsTemplateEngine', (): void => {
|
|
const template = { templateString: 'xyz' };
|
|
const contents = { detail: 'a&b' };
|
|
let templateEngine: HandlebarsTemplateEngine;
|
|
|
|
beforeEach((): void => {
|
|
templateEngine = new HandlebarsTemplateEngine('http://localhost:3000/', template);
|
|
});
|
|
|
|
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');
|
|
});
|
|
});
|