mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 04:02:12 +00:00
moved tests to fetch, run prettier
This commit is contained in:
parent
92a35692f2
commit
f09c54184a
@ -7,7 +7,7 @@
|
|||||||
const Log = require("logger");
|
const Log = require("logger");
|
||||||
const ical = require("node-ical");
|
const ical = require("node-ical");
|
||||||
const fetch = require("digest-fetch");
|
const fetch = require("digest-fetch");
|
||||||
const https = require('https');
|
const https = require("https");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moment date
|
* Moment date
|
||||||
@ -55,7 +55,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
|
|
||||||
if (selfSignedCert) {
|
if (selfSignedCert) {
|
||||||
httpsAgent = new https.Agent({
|
httpsAgent = new https.Agent({
|
||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,20 +75,20 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
}
|
}
|
||||||
|
|
||||||
const client = new fetch(user, password);
|
const client = new fetch(user, password);
|
||||||
client.fetch(url, { headers: headers, httpsAgent: httpsAgent })
|
client
|
||||||
.catch(error => {
|
.fetch(url, { headers: headers, httpsAgent: httpsAgent })
|
||||||
|
.catch((error) => {
|
||||||
fetchFailedCallback(self, error);
|
fetchFailedCallback(self, error);
|
||||||
scheduleTimer();
|
scheduleTimer();
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then((response) => {
|
||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
throw new Error(response.status + ": " + response.statusText);
|
throw new Error(response.status + ": " + response.statusText);
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
})
|
})
|
||||||
.then(response => response.text())
|
.then((response) => response.text())
|
||||||
.then(responseData => {
|
.then((responseData) => {
|
||||||
|
|
||||||
let data = [];
|
let data = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -86,14 +86,13 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetch(url, { headers: headers })
|
fetch(url, { headers: headers })
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
fetchFailedCallback(self, error);
|
fetchFailedCallback(self, error);
|
||||||
scheduleTimer();
|
scheduleTimer();
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then((res) => {
|
||||||
res.body.pipe(iconv.decodeStream(encoding)).pipe(parser);
|
res.body.pipe(iconv.decodeStream(encoding)).pipe(parser);
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
const request = require("request");
|
const fetch = require("node-fetch");
|
||||||
const expect = require("chai").expect;
|
const expect = require("chai").expect;
|
||||||
|
|
||||||
const describe = global.describe;
|
const describe = global.describe;
|
||||||
@ -46,15 +46,15 @@ describe("Electron app environment", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("get request from http://localhost:8080 should return 200", function (done) {
|
it("get request from http://localhost:8080 should return 200", function (done) {
|
||||||
request.get("http://localhost:8080", function (err, res, body) {
|
fetch("http://localhost:8080").then((res) => {
|
||||||
expect(res.statusCode).to.equal(200);
|
expect(res.status).to.equal(200);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("get request from http://localhost:8080/nothing should return 404", function (done) {
|
it("get request from http://localhost:8080/nothing should return 404", function (done) {
|
||||||
request.get("http://localhost:8080/nothing", function (err, res, body) {
|
fetch("http://localhost:8080/nothing").then((res) => {
|
||||||
expect(res.statusCode).to.equal(404);
|
expect(res.status).to.equal(404);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
const request = require("request");
|
const fetch = require("node-fetch");
|
||||||
const expect = require("chai").expect;
|
const expect = require("chai").expect;
|
||||||
const forEach = require("mocha-each");
|
const forEach = require("mocha-each");
|
||||||
|
|
||||||
@ -40,8 +40,8 @@ describe("All font files from roboto.css should be downloadable", function () {
|
|||||||
|
|
||||||
forEach(fontFiles).it("should return 200 HTTP code for file '%s'", (fontFile, done) => {
|
forEach(fontFiles).it("should return 200 HTTP code for file '%s'", (fontFile, done) => {
|
||||||
var fontUrl = "http://localhost:8080/fonts/" + fontFile;
|
var fontUrl = "http://localhost:8080/fonts/" + fontFile;
|
||||||
request.get(fontUrl, function (err, res, body) {
|
fetch(fontUrl).then((res) => {
|
||||||
expect(res.statusCode).to.equal(200);
|
expect(res.status).to.equal(200);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
const request = require("request");
|
const fetch = require("node-fetch");
|
||||||
const expect = require("chai").expect;
|
const expect = require("chai").expect;
|
||||||
|
|
||||||
const describe = global.describe;
|
const describe = global.describe;
|
||||||
@ -32,8 +32,8 @@ describe("ipWhitelist directive configuration", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/noIpWhiteList.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/noIpWhiteList.js";
|
||||||
});
|
});
|
||||||
it("should return 403", function (done) {
|
it("should return 403", function (done) {
|
||||||
request.get("http://localhost:8080", function (err, res, body) {
|
fetch("http://localhost:8080").then((res) => {
|
||||||
expect(res.statusCode).to.equal(403);
|
expect(res.status).to.equal(403);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -45,8 +45,8 @@ describe("ipWhitelist directive configuration", function () {
|
|||||||
process.env.MM_CONFIG_FILE = "tests/configs/empty_ipWhiteList.js";
|
process.env.MM_CONFIG_FILE = "tests/configs/empty_ipWhiteList.js";
|
||||||
});
|
});
|
||||||
it("should return 200", function (done) {
|
it("should return 200", function (done) {
|
||||||
request.get("http://localhost:8080", function (err, res, body) {
|
fetch("http://localhost:8080").then((res) => {
|
||||||
expect(res.statusCode).to.equal(200);
|
expect(res.status).to.equal(200);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
const request = require("request");
|
const fetch = require("node-fetch");
|
||||||
const expect = require("chai").expect;
|
const expect = require("chai").expect;
|
||||||
|
|
||||||
const describe = global.describe;
|
const describe = global.describe;
|
||||||
@ -33,8 +33,8 @@ describe("port directive configuration", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should return 200", function (done) {
|
it("should return 200", function (done) {
|
||||||
request.get("http://localhost:8090", function (err, res, body) {
|
fetch("http://localhost:8090").then((res) => {
|
||||||
expect(res.statusCode).to.equal(200);
|
expect(res.status).to.equal(200);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -52,8 +52,8 @@ describe("port directive configuration", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should return 200", function (done) {
|
it("should return 200", function (done) {
|
||||||
request.get("http://localhost:8100", function (err, res, body) {
|
fetch("http://localhost:8100").then((res) => {
|
||||||
expect(res.statusCode).to.equal(200);
|
expect(res.status).to.equal(200);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const helpers = require("./global-setup");
|
const helpers = require("./global-setup");
|
||||||
const request = require("request");
|
const fetch = require("node-fetch");
|
||||||
const expect = require("chai").expect;
|
const expect = require("chai").expect;
|
||||||
|
|
||||||
const describe = global.describe;
|
const describe = global.describe;
|
||||||
@ -32,8 +32,8 @@ describe("Vendors", function () {
|
|||||||
Object.keys(vendors).forEach((vendor) => {
|
Object.keys(vendors).forEach((vendor) => {
|
||||||
it(`should return 200 HTTP code for vendor "${vendor}"`, function () {
|
it(`should return 200 HTTP code for vendor "${vendor}"`, function () {
|
||||||
var urlVendor = "http://localhost:8080/vendor/" + vendors[vendor];
|
var urlVendor = "http://localhost:8080/vendor/" + vendors[vendor];
|
||||||
request.get(urlVendor, function (err, res, body) {
|
fetch(urlVendor).then((res) => {
|
||||||
expect(res.statusCode).to.equal(200);
|
expect(res.status).to.equal(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -41,8 +41,8 @@ describe("Vendors", function () {
|
|||||||
Object.keys(vendors).forEach((vendor) => {
|
Object.keys(vendors).forEach((vendor) => {
|
||||||
it(`should return 404 HTTP code for vendor https://localhost/"${vendor}"`, function () {
|
it(`should return 404 HTTP code for vendor https://localhost/"${vendor}"`, function () {
|
||||||
var urlVendor = "http://localhost:8080/" + vendors[vendor];
|
var urlVendor = "http://localhost:8080/" + vendors[vendor];
|
||||||
request.get(urlVendor, function (err, res, body) {
|
fetch(urlVendor).then((res) => {
|
||||||
expect(res.statusCode).to.equal(404);
|
expect(res.status).to.equal(404);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user