feat: Moved IDP response and template behaviour to single class

This commit is contained in:
Joachim Van Herwegen
2021-07-29 16:31:37 +02:00
parent 2a82c4f06e
commit 9d337ba80c
42 changed files with 662 additions and 734 deletions

View File

@@ -5,6 +5,7 @@ import type { TemplateEngine } from '../../../../src/util/templates/TemplateEngi
describe('A TemplateHandler', (): void => {
const contents = { contents: 'contents' };
const templateFile = '/templates/main.html.ejs';
let templateEngine: jest.Mocked<TemplateEngine>;
let response: HttpResponse;
@@ -17,10 +18,10 @@ describe('A TemplateHandler', (): void => {
it('renders the template in the response.', async(): Promise<void> => {
const handler = new TemplateHandler(templateEngine);
await handler.handle({ response, contents });
await handler.handle({ response, contents, templateFile });
expect(templateEngine.render).toHaveBeenCalledTimes(1);
expect(templateEngine.render).toHaveBeenCalledWith(contents);
expect(templateEngine.render).toHaveBeenCalledWith(contents, { templateFile });
expect(response.getHeaders()).toHaveProperty('content-type', 'text/html');
expect((response as any)._isEndCalled()).toBe(true);