/ packages / string-templates / test / renderApp.spec.ts
renderApp.spec.ts
 1  import { processString } from "../src/index"
 2  
 3  describe("specific test case for whether or not full app template can still be rendered", () => {
 4    it("should be able to render the app template", async () => {
 5      const template = `<!doctype html>
 6          <html>
 7          <head>
 8            {{{head}}}
 9          </head>
10          <script>
11            window["##BUDIBASE_APP_ID##"] = "{{appId}}"
12          </script>
13          {{{body}}}
14          </html>`
15      const context = {
16        appId: "App1",
17        head: "<title>App</title>",
18        body: "<body><p>App things</p></body>",
19      }
20      const output = await processString(template, context)
21      expect(output).toBe(`<!doctype html>
22          <html>
23          <head>
24            <title>App</title>
25          </head>
26          <script>
27            window["##BUDIBASE_APP_ID##"] = "App1"
28          </script>
29          <body><p>App things</p></body>
30          </html>`)
31    })
32  })