From 0d0b86fb5b40e40cc941bc22a3b67b39600d5b84 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 12 Jul 2022 13:28:05 +0200 Subject: [PATCH] techdocs-backend: fix http mock in cacheMiddleware test Signed-off-by: Patrik Oldsberg --- .../src/cache/cacheMiddleware.test.ts | 25 +++++++++++-------- .../src/service/router.test.ts | 25 +++++++++++-------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/plugins/techdocs-backend/src/cache/cacheMiddleware.test.ts b/plugins/techdocs-backend/src/cache/cacheMiddleware.test.ts index b6a0f7db56..0a21eddc15 100644 --- a/plugins/techdocs-backend/src/cache/cacheMiddleware.test.ts +++ b/plugins/techdocs-backend/src/cache/cacheMiddleware.test.ts @@ -23,17 +23,20 @@ import { createCacheMiddleware, TechDocsCache } from '.'; * Mocks cached HTTP response. */ const getMockHttpResponseFor = (content: string): Buffer => { - return Buffer.concat([ - Buffer.from(`HTTP/1.1 200 OK -Content-Type: text/plain; charset=utf-8 -Accept-Ranges: bytes -Cache-Control: public, max-age=0 -Last-Modified: Sat, 1 Jul 2021 12:00:00 GMT -Date: Sat, 1 Jul 2021 12:00:00 GMT -Connection: close -Content-Length: ${content.length}\n\n`), - Buffer.from(content), - ]); + return Buffer.from( + [ + 'HTTP/1.1 200 OK', + 'Content-Type: text/plain; charset=utf-8', + 'Accept-Ranges: bytes', + 'Cache-Control: public, max-age=0', + 'Last-Modified: Sat, 1 Jul 2021 12:00:00 GMT', + 'Date: Sat, 1 Jul 2021 12:00:00 GMT', + 'Connection: close', + `Content-Length: ${content.length}`, + '', + content, + ].join('\r\n'), + ); }; /** diff --git a/plugins/techdocs-backend/src/service/router.test.ts b/plugins/techdocs-backend/src/service/router.test.ts index f3f9892f44..9edd2e3edc 100644 --- a/plugins/techdocs-backend/src/service/router.test.ts +++ b/plugins/techdocs-backend/src/service/router.test.ts @@ -56,17 +56,20 @@ const MockTechDocsCache = { TechDocsCache.fromConfig = () => MockTechDocsCache; const getMockHttpResponseFor = (content: string): Buffer => { - return Buffer.concat([ - Buffer.from(`HTTP/1.1 200 OK -Content-Type: text/plain; charset=utf-8 -Accept-Ranges: bytes -Cache-Control: public, max-age=0 -Last-Modified: Sat, 1 Jul 2021 12:00:00 GMT -Date: Sat, 1 Jul 2021 12:00:00 GMT -Connection: close -Content-Length: ${content.length}\n\n`), - Buffer.from(content), - ]); + return Buffer.from( + [ + 'HTTP/1.1 200 OK', + 'Content-Type: text/plain; charset=utf-8', + 'Accept-Ranges: bytes', + 'Cache-Control: public, max-age=0', + 'Last-Modified: Sat, 1 Jul 2021 12:00:00 GMT', + 'Date: Sat, 1 Jul 2021 12:00:00 GMT', + 'Connection: close', + `Content-Length: ${content.length}`, + '', + content, + ].join('\r\n'), + ); }; const createApp = async (options: RouterOptions) => {