2017-10-03 10:52:31 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const expect = require("chai").expect;
|
|
|
|
const fs = require("fs");
|
|
|
|
const path = require("path");
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
describe("public folder", function () {
|
2017-10-03 10:52:31 +00:00
|
|
|
const publicFolder = path.join(__dirname, "..", "..", "public");
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
it("font awesome files are copied", function () {
|
2017-12-08 04:01:58 +00:00
|
|
|
expect(fs.existsSync(path.join(publicFolder, "fonts", "fa-solid-900.woff"))).to.be.true;
|
|
|
|
expect(fs.existsSync(path.join(publicFolder, "fonts", "fa-solid-900.woff2"))).to.be.true;
|
2017-10-03 10:52:31 +00:00
|
|
|
});
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
it("files in root folder are copied", function () {
|
2019-03-18 10:52:12 +00:00
|
|
|
expect(fs.existsSync(path.join(publicFolder, "favicon.ico"))).to.be.true;
|
|
|
|
expect(fs.existsSync(path.join(publicFolder, "robots.txt"))).to.be.true;
|
|
|
|
expect(fs.existsSync(path.join(publicFolder, "service-worker.js"))).to.be.true;
|
|
|
|
expect(fs.existsSync(path.join(publicFolder, "thelounge.webmanifest"))).to.be.true;
|
|
|
|
});
|
|
|
|
|
2020-05-16 18:32:33 +00:00
|
|
|
it("audio files are copied", function () {
|
|
|
|
expect(fs.existsSync(path.join(publicFolder, "audio", "pop.wav"))).to.be.true;
|
|
|
|
});
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
it("index HTML file is not copied", function () {
|
2018-01-14 00:46:59 +00:00
|
|
|
expect(fs.existsSync(path.join(publicFolder, "index.html"))).to.be.false;
|
|
|
|
expect(fs.existsSync(path.join(publicFolder, "index.html.tpl"))).to.be.false;
|
2017-10-03 10:52:31 +00:00
|
|
|
});
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
it("javascript files are built", function () {
|
2017-10-03 10:52:31 +00:00
|
|
|
expect(fs.existsSync(path.join(publicFolder, "js", "bundle.js"))).to.be.true;
|
|
|
|
expect(fs.existsSync(path.join(publicFolder, "js", "bundle.vendor.js"))).to.be.true;
|
|
|
|
});
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
it("style files are built", function () {
|
2019-03-18 10:52:12 +00:00
|
|
|
expect(fs.existsSync(path.join(publicFolder, "css", "style.css"))).to.be.true;
|
|
|
|
expect(fs.existsSync(path.join(publicFolder, "css", "style.css.map"))).to.be.true;
|
2020-05-16 18:32:33 +00:00
|
|
|
expect(fs.existsSync(path.join(publicFolder, "themes", "default.css"))).to.be.true;
|
|
|
|
expect(fs.existsSync(path.join(publicFolder, "themes", "morning.css"))).to.be.true;
|
2019-03-18 10:52:12 +00:00
|
|
|
});
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
it("style files contain expected content", function (done) {
|
|
|
|
fs.readFile(path.join(publicFolder, "css", "style.css"), "utf8", function (err, contents) {
|
2019-11-02 10:53:38 +00:00
|
|
|
expect(err).to.be.null;
|
|
|
|
|
|
|
|
expect(contents.includes("var(--body-color)")).to.be.true;
|
|
|
|
expect(contents.includes("url(../fonts/fa-solid-900.woff2)")).to.be.true;
|
|
|
|
expect(contents.includes(".tooltipped{position:relative}")).to.be.true;
|
|
|
|
expect(contents.includes("sourceMappingURL")).to.be.true;
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
it("javascript map is created", function () {
|
2017-10-03 10:52:31 +00:00
|
|
|
expect(fs.existsSync(path.join(publicFolder, "js", "bundle.js.map"))).to.be.true;
|
|
|
|
});
|
|
|
|
|
2020-03-21 20:55:36 +00:00
|
|
|
it("loading-error-handlers.js is copied", function () {
|
2019-07-17 09:33:59 +00:00
|
|
|
expect(fs.existsSync(path.join(publicFolder, "js", "loading-error-handlers.js"))).to.be
|
|
|
|
.true;
|
2017-10-03 10:52:31 +00:00
|
|
|
});
|
2020-05-16 18:32:33 +00:00
|
|
|
|
|
|
|
it("service worker has cacheName set", function (done) {
|
|
|
|
fs.readFile(path.join(publicFolder, "service-worker.js"), "utf8", function (err, contents) {
|
|
|
|
expect(err).to.be.null;
|
|
|
|
|
|
|
|
expect(contents.includes("const cacheName =")).to.be.true;
|
|
|
|
expect(contents.includes("__HASH__")).to.be.false;
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2017-10-03 10:52:31 +00:00
|
|
|
});
|