MagicMirror/tests/e2e/fonts.js

29 lines
936 B
JavaScript
Raw Normal View History

2021-09-16 22:36:18 +02:00
const helpers = require("./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
2021-03-17 22:34:32 +01:00
const fileContent = require("fs").readFileSync(__dirname + "/../../fonts/roboto.css", "utf8");
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(() => {
2021-09-25 23:45:34 +02:00
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
});
test.each(fontFiles)("should return 200 HTTP code for file '%s'", async (fontFile) => {
2021-03-17 22:34:32 +01:00
const fontUrl = "http://localhost:8080/fonts/" + fontFile;
const res = await helpers.fetch(fontUrl);
expect(res.status).toBe(200);
2017-08-21 14:44:47 +02:00
});
});