From af4be53a14df45d9ab1d79f1a122cd74dec010b2 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 21 Nov 2024 16:38:32 +0100 Subject: [PATCH] app-backend: refactor config inject test + add more cases Signed-off-by: Patrik Oldsberg --- .../app-backend/src/service/appPlugin.test.ts | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/plugins/app-backend/src/service/appPlugin.test.ts b/plugins/app-backend/src/service/appPlugin.test.ts index bb5f92b536..fbb0747a64 100644 --- a/plugins/app-backend/src/service/appPlugin.test.ts +++ b/plugins/app-backend/src/service/appPlugin.test.ts @@ -93,34 +93,37 @@ describe('appPlugin', () => { ], }); - const rootContent = await fetch( - `http://localhost:${server.port()}?foo=bar`, - ).then(res => res.text()); - - expect(rootContent).toBe(` + const baseUrl = `http://localhost:${server.port()}`; + const withInjectedConfig = ` -`); +`; - const indexContent = await fetch( - `http://localhost:${server.port()}/index.html`, - ).then(res => res.text()); + await expect(fetch(`${baseUrl}`).then(res => res.text())).resolves.toBe( + withInjectedConfig, + ); - expect(indexContent).toBe(` - -`); + await expect( + fetch(`${baseUrl}?foo=bar`).then(res => res.text()), + ).resolves.toBe(withInjectedConfig); - const htmlContent = await fetch( - `http://localhost:${server.port()}/api/app/some/html5/route`, - ).then(res => res.text()); + await expect( + fetch(`${baseUrl}/index.html`).then(res => res.text()), + ).resolves.toBe(withInjectedConfig); - expect(htmlContent).toBe(` - -`); + await expect( + fetch(`${baseUrl}/index.html?foo=bar`).then(res => res.text()), + ).resolves.toBe(withInjectedConfig); + + await expect( + fetch(`${baseUrl}/api/app/some/html5/route`).then(res => res.text()), + ).resolves.toBe(withInjectedConfig); + + await expect( + fetch(`${baseUrl}/api/app/some/html5/route?foo=bar`).then(res => + res.text(), + ), + ).resolves.toBe(withInjectedConfig); }); });