MagicMirror/tests/e2e/env_spec.js

56 lines
1.5 KiB
JavaScript
Raw Normal View History

const helpers = require("./global-setup");
2021-03-02 21:26:25 +01:00
const fetch = require("node-fetch");
describe("Electron app environment", function () {
helpers.setupTimeout(this);
2021-04-08 21:12:56 +02:00
let app = null;
2017-01-30 12:29:32 -03:00
2021-06-08 00:47:40 +02:00
beforeAll(function () {
// Set config sample for use in test
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
});
beforeEach(function () {
return helpers
.startApplication({
args: ["js/electron.js"]
})
.then(function (startedApp) {
app = startedApp;
});
2017-01-30 12:29:32 -03:00
});
afterEach(function () {
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-06-08 00:47:40 +02:00
expect(await app.client.getWindowCount()).toBe(1);
expect(await app.browserWindow.isMinimized()).toBe(false);
expect(await app.browserWindow.isDevToolsOpened()).toBe(false);
expect(await app.browserWindow.isVisible()).toBe(true);
expect(await app.browserWindow.isFocused()).toBe(true);
2021-01-30 20:29:59 +01:00
const bounds = await app.browserWindow.getBounds();
2021-06-08 00:47:40 +02:00
expect(bounds.width).toBeGreaterThan(0);
expect(bounds.height).toBeGreaterThan(0);
expect(await app.browserWindow.getTitle()).toBe("MagicMirror²");
2017-01-30 12:29:32 -03: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) => {
2021-06-08 00:47:40 +02:00
expect(res.status).toBe(200);
done();
});
});
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) => {
2021-06-08 00:47:40 +02:00
expect(res.status).toBe(404);
done();
});
});
2017-01-30 12:29:32 -03:00
});