From 6f95b2c2adefaa575ad502cac1df5fedceb30336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Wed, 1 Feb 2017 14:33:17 -0300 Subject: [PATCH] add test with displaySeconds config disabled for clock module --- .../clock/clock_displaySeconds_false.js | 32 +++++++++++++++++++ tests/e2e/modules/clock_spec.js | 22 +++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/configs/modules/clock/clock_displaySeconds_false.js diff --git a/tests/configs/modules/clock/clock_displaySeconds_false.js b/tests/configs/modules/clock/clock_displaySeconds_false.js new file mode 100644 index 00000000..91bbebba --- /dev/null +++ b/tests/configs/modules/clock/clock_displaySeconds_false.js @@ -0,0 +1,32 @@ +/* Magic Mirror Test config for default clock module + * + * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com + * MIT Licensed. + */ + +var config = { + port: 8080, + ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], + + language: "en", + timeFormat: 12, + units: "metric", + electronOptions: { + webPreferences: { + nodeIntegration: true, + }, + }, + + modules: [ + { + module: "clock", + position: "middle_center", + config: { + displaySeconds: false + } + } + ] +}; + +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") {module.exports = config;} diff --git a/tests/e2e/modules/clock_spec.js b/tests/e2e/modules/clock_spec.js index 860cc6f0..6b686a1e 100644 --- a/tests/e2e/modules/clock_spec.js +++ b/tests/e2e/modules/clock_spec.js @@ -100,4 +100,26 @@ describe("Clock module", function () { .getText(".clock .time").should.eventually.match(timeRegex); }); }); + + describe("with displaySeconds config disabled", function() { + before(function() { + // Set config sample for use in test + process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_displaySeconds_false.js"; + }); + + beforeEach(function (done) { + app.start().then(function() { done(); } ); + }); + + afterEach(function (done) { + app.stop().then(function() { done(); }); + }); + + it("shows 12hr time without seconds am/pm", function() { + const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[ap]m$/; + return app.client.waitUntilWindowLoaded() + .getText(".clock .time").should.eventually.match(timeRegex); + }); + }); + });