use internal fetch function of node instead external node-fetch library if node version >= v18

This commit is contained in:
Karsten Hassel
2022-05-27 19:46:28 +02:00
parent cbda20f67e
commit 0023c64d59
23 changed files with 69 additions and 46 deletions

View File

@@ -1,4 +1,4 @@
const fetch = require("node-fetch");
const fetch = require("fetch");
const helpers = require("./global-setup");
describe("App environment", function () {
@@ -6,8 +6,8 @@ describe("App environment", function () {
helpers.startApplication("tests/configs/default.js");
helpers.getDocument(done);
});
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
it("get request from http://localhost:8080 should return 200", function (done) {

View File

@@ -1,4 +1,4 @@
const fetch = require("node-fetch");
const fetch = require("fetch");
const helpers = require("./global-setup");
describe("All font files from roboto.css should be downloadable", function () {
@@ -17,8 +17,8 @@ describe("All font files from roboto.css should be downloadable", function () {
beforeAll(function () {
helpers.startApplication("tests/configs/without_modules.js");
});
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
test.each(fontFiles)("should return 200 HTTP code for file '%s'", (fontFile, done) => {

View File

@@ -16,10 +16,11 @@ exports.startApplication = function (configFilename, exec) {
global.app.start();
};
exports.stopApplication = function () {
exports.stopApplication = async function () {
if (global.app) {
global.app.stop();
}
await new Promise((resolve) => setTimeout(resolve, 100));
};
exports.getDocument = function (callback) {

View File

@@ -1,4 +1,4 @@
const fetch = require("node-fetch");
const fetch = require("fetch");
const helpers = require("./global-setup");
describe("ipWhitelist directive configuration", function () {
@@ -6,8 +6,8 @@ describe("ipWhitelist directive configuration", function () {
beforeAll(function () {
helpers.startApplication("tests/configs/noIpWhiteList.js");
});
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
it("should return 403", function (done) {
@@ -22,8 +22,8 @@ describe("ipWhitelist directive configuration", function () {
beforeAll(function () {
helpers.startApplication("tests/configs/empty_ipWhiteList.js");
});
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
it("should return 200", function (done) {

View File

@@ -5,8 +5,8 @@ describe("Alert module", function () {
helpers.startApplication("tests/configs/modules/alert/default.js");
helpers.getDocument(done);
});
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
it("should show the welcome message", function () {

View File

@@ -25,8 +25,8 @@ describe("Calendar module", function () {
});
};
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
describe("Default configuration", function () {

View File

@@ -1,8 +1,8 @@
const helpers = require("../global-setup");
describe("Clock set to spanish language module", function () {
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
const testMatch = function (element, regex) {

View File

@@ -2,8 +2,8 @@ const helpers = require("../global-setup");
const moment = require("moment");
describe("Clock module", function () {
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
const testMatch = function (element, regex) {

View File

@@ -16,8 +16,8 @@ function doTest(complimentsArray) {
}
describe("Compliments module", function () {
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
describe("parts of days", function () {

View File

@@ -1,8 +1,8 @@
const helpers = require("../global-setup");
describe("Test helloworld module", function () {
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
describe("helloworld set config text", function () {

View File

@@ -1,8 +1,8 @@
const helpers = require("../global-setup");
describe("Newsfeed module", function () {
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
describe("Default configuration", function () {

View File

@@ -40,8 +40,8 @@ describe("Weather module", function () {
helpers.getDocument(callback);
}
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
describe("Current weather", function () {

View File

@@ -5,8 +5,8 @@ describe("Display of modules", function () {
helpers.startApplication("tests/configs/modules/display.js");
helpers.getDocument(done);
});
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
it("should show the test header", function () {

View File

@@ -5,8 +5,8 @@ describe("Position of modules", function () {
helpers.startApplication("tests/configs/modules/positions.js");
helpers.getDocument(done);
});
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
const positions = ["top_bar", "top_left", "top_center", "top_right", "upper_third", "middle_center", "lower_third", "bottom_left", "bottom_center", "bottom_right", "bottom_bar", "fullscreen_above", "fullscreen_below"];

View File

@@ -1,4 +1,4 @@
const fetch = require("node-fetch");
const fetch = require("fetch");
const helpers = require("./global-setup");
describe("port directive configuration", function () {
@@ -6,8 +6,8 @@ describe("port directive configuration", function () {
beforeAll(function () {
helpers.startApplication("tests/configs/port_8090.js");
});
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
it("should return 200", function (done) {
@@ -22,8 +22,8 @@ describe("port directive configuration", function () {
beforeAll(function () {
helpers.startApplication("tests/configs/port_8090.js", (process.env.MM_PORT = 8100));
});
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
it("should return 200", function (done) {

View File

@@ -1,12 +1,12 @@
const fetch = require("node-fetch");
const fetch = require("fetch");
const helpers = require("./global-setup");
describe("Vendors", function () {
beforeAll(function () {
helpers.startApplication("tests/configs/default.js");
});
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
describe("Get list vendors", function () {

View File

@@ -5,8 +5,8 @@ describe("Check configuration without modules", function () {
helpers.startApplication("tests/configs/without_modules.js");
helpers.getDocument(done);
});
afterAll(function () {
helpers.stopApplication();
afterAll(async function () {
await helpers.stopApplication();
});
it("Show the message MagicMirror² title", function () {