2019-07-19 09:13:39 +02:00
|
|
|
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);
|
|
|
|
|
2019-07-25 08:31:54 +02:00
|
|
|
const expectedIndexHtml = await readFile("appPackages/testApp/public/unauthenticated/index.html", "utf8");
|
2019-07-19 09:13:39 +02:00
|
|
|
|
|
|
|
expect(response.text).toBe(expectedIndexHtml);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should serve specified files when unauthenticated", async () => {
|
|
|
|
const response = await app.get("/testApp/app.js")
|
|
|
|
.expect(statusCodes.OK);
|
|
|
|
|
2019-07-25 08:31:54 +02:00
|
|
|
const expectedFile = await readFile("appPackages/testApp/public/unauthenticated/app.js", "utf8");
|
2019-07-19 09:13:39 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2019-07-25 08:31:54 +02:00
|
|
|
const expectedIndexHtml = await readFile("appPackages/testApp/public/main/index.html", "utf8");
|
2019-07-19 09:13:39 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2019-07-25 08:31:54 +02:00
|
|
|
const expectedFile = await readFile("appPackages/testApp/public/main/app.js", "utf8");
|
2019-07-19 09:13:39 +02:00
|
|
|
|
|
|
|
expect(response.text).toBe(expectedFile);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|