1
0
Fork 0
mirror of synced 2024-09-07 21:21:12 +12:00
budibase/packages/server/tests/serveui.js
2019-07-19 08:13:39 +01:00

48 lines
No EOL
1.7 KiB
JavaScript

const statusCodes = require("../utilities/statusCodes");
const { readFile } = require("../utilities/fsawait");
module.exports = (app) => {
it("should serve unauthenticated index.html as default", async () => {
const response = await app.get("/testApp")
.expect(statusCodes.OK);
const expectedIndexHtml = await readFile("appPackages/testApp/ui/unauthenticated/public/index.html", "utf8");
expect(response.text).toBe(expectedIndexHtml);
});
it("should serve specified files when unauthenticated", async () => {
const response = await app.get("/testApp/app.js")
.expect(statusCodes.OK);
const expectedFile = await readFile("appPackages/testApp/ui/unauthenticated/public/app.js", "utf8");
expect(response.text).toBe(expectedFile);
});
it("should serve main index.html as default when authenticated", async () => {
const response = await app.get("/testApp")
.set("cookie", app.credentials.testAppUser1.cookie)
.expect(statusCodes.OK);
const expectedIndexHtml = await readFile("appPackages/testApp/ui/main/public/index.html", "utf8");
expect(response.text).toBe(expectedIndexHtml);
});
it("should serve specified files when authenticated", async () => {
const response = await app.get("/testApp/app.js")
.set("cookie", app.credentials.testAppUser1.cookie)
.expect(statusCodes.OK);
const expectedFile = await readFile("appPackages/testApp/ui/main/public/app.js", "utf8");
expect(response.text).toBe(expectedFile);
});
}