2017-07-24 22:08:12 +02:00
|
|
|
const helpers = require("./global-setup");
|
2021-03-02 21:26:25 +01:00
|
|
|
const fetch = require("node-fetch");
|
2017-07-24 22:08:12 +02:00
|
|
|
const expect = require("chai").expect;
|
|
|
|
|
|
|
|
const describe = global.describe;
|
|
|
|
const it = global.it;
|
|
|
|
const beforeEach = global.beforeEach;
|
|
|
|
const afterEach = global.afterEach;
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("Electron app environment", function () {
|
2017-07-24 22:08:12 +02:00
|
|
|
helpers.setupTimeout(this);
|
|
|
|
|
2021-04-08 21:12:56 +02:00
|
|
|
let app = null;
|
2017-01-30 12:29:32 -03:00
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
before(function () {
|
2017-01-31 10:37:03 -08:00
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
beforeEach(function () {
|
2017-07-24 22:08:12 +02:00
|
|
|
return helpers
|
|
|
|
.startApplication({
|
|
|
|
args: ["js/electron.js"]
|
|
|
|
})
|
2020-05-11 22:22:32 +02:00
|
|
|
.then(function (startedApp) {
|
2017-07-24 22:08:12 +02:00
|
|
|
app = startedApp;
|
|
|
|
});
|
2017-01-30 12:29:32 -03:00
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
afterEach(function () {
|
2017-07-24 22:08:12 +02:00
|
|
|
return helpers.stopApplication(app);
|
2017-01-30 12:29:32 -03:00
|
|
|
});
|
|
|
|
|
2021-01-30 20:29:59 +01:00
|
|
|
it("should open a browserwindow", async function () {
|
|
|
|
await app.client.waitUntilWindowLoaded();
|
|
|
|
app.browserWindow.focus();
|
2021-02-06 23:52:44 +01:00
|
|
|
expect(await app.client.getWindowCount()).to.equal(1);
|
|
|
|
expect(await app.browserWindow.isMinimized()).to.be.false;
|
|
|
|
expect(await app.browserWindow.isDevToolsOpened()).to.be.false;
|
|
|
|
expect(await app.browserWindow.isVisible()).to.be.true;
|
|
|
|
expect(await app.browserWindow.isFocused()).to.be.true;
|
2021-01-30 20:29:59 +01:00
|
|
|
const bounds = await app.browserWindow.getBounds();
|
2021-02-06 23:52:44 +01:00
|
|
|
expect(bounds.width).to.be.above(0);
|
|
|
|
expect(bounds.height).to.be.above(0);
|
|
|
|
expect(await app.browserWindow.getTitle()).to.equal("MagicMirror²");
|
2017-01-30 12:29:32 -03:00
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
it("get request from http://localhost:8080 should return 200", function (done) {
|
2021-03-02 21:26:25 +01:00
|
|
|
fetch("http://localhost:8080").then((res) => {
|
|
|
|
expect(res.status).to.equal(200);
|
2017-03-08 10:36:08 -03:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
it("get request from http://localhost:8080/nothing should return 404", function (done) {
|
2021-03-02 21:26:25 +01:00
|
|
|
fetch("http://localhost:8080/nothing").then((res) => {
|
|
|
|
expect(res.status).to.equal(404);
|
2017-03-09 17:10:32 -03:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2017-01-30 12:29:32 -03:00
|
|
|
});
|