MagicMirror/tests/e2e/fonts_spec.js

29 lines
946 B
JavaScript
Raw Normal View History

const helpers = require("./helpers/global-setup");
2017-08-21 14:44:47 +02:00
describe("All font files from roboto.css should be downloadable", () => {
2021-03-17 22:34:32 +01:00
const fontFiles = [];
2017-08-21 14:44:47 +02:00
// Statements below filters out all 'url' lines in the CSS file
const fileContent = require("fs").readFileSync(`${__dirname}/../../fonts/roboto.css`, "utf8");
2021-03-17 22:34:32 +01:00
const regex = /\burl\(['"]([^'"]+)['"]\)/g;
let match = regex.exec(fileContent);
2019-06-05 09:32:10 +02:00
while (match !== null) {
2017-08-21 14:44:47 +02:00
// Push 1st match group onto fontFiles stack
fontFiles.push(match[1]);
// Find the next one
match = regex.exec(fileContent);
}
beforeAll(async () => {
await helpers.startApplication("tests/configs/without_modules.js");
2017-08-21 14:44:47 +02:00
});
afterAll(async () => {
await helpers.stopApplication();
2017-08-21 14:44:47 +02:00
});
it.each(fontFiles)("should return 200 HTTP code for file '%s'", async (fontFile) => {
const fontUrl = `http://localhost:8080/fonts/${fontFile}`;
const res = await fetch(fontUrl);
expect(res.status).toBe(200);
2017-08-21 14:44:47 +02:00
});
});