2021-03-02 21:26:25 +01:00
|
|
|
const fetch = require("node-fetch");
|
2021-09-16 22:36:18 +02:00
|
|
|
const helpers = require("./global-setup");
|
2017-08-21 14:44:47 +02:00
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("All font files from roboto.css should be downloadable", function () {
|
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);
|
|
|
|
}
|
|
|
|
|
2021-06-08 00:47:40 +02:00
|
|
|
beforeAll(function () {
|
2021-09-25 23:45:34 +02:00
|
|
|
helpers.startApplication("tests/configs/without_modules.js");
|
2017-08-21 14:44:47 +02:00
|
|
|
});
|
2021-06-08 00:47:40 +02:00
|
|
|
afterAll(function () {
|
2021-09-25 23:45:34 +02:00
|
|
|
helpers.stopApplication();
|
2017-08-21 14:44:47 +02:00
|
|
|
});
|
|
|
|
|
2021-06-09 00:19:43 +02:00
|
|
|
test.each(fontFiles)("should return 200 HTTP code for file '%s'", (fontFile, done) => {
|
2021-03-17 22:34:32 +01:00
|
|
|
const fontUrl = "http://localhost:8080/fonts/" + fontFile;
|
2021-03-02 21:26:25 +01:00
|
|
|
fetch(fontUrl).then((res) => {
|
2021-06-09 00:19:43 +02:00
|
|
|
expect(res.status).toBe(200);
|
2017-08-21 14:44:47 +02:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|