2017-02-19 21:06:38 -03:00
|
|
|
const globalSetup = require("../global-setup");
|
|
|
|
const app = globalSetup.app;
|
2017-01-31 10:37:03 -08:00
|
|
|
|
|
|
|
describe("Clock module", function () {
|
2017-02-12 15:36:18 -03:00
|
|
|
this.timeout(20000);
|
2017-01-31 10:37:03 -08:00
|
|
|
|
|
|
|
describe("with default 24hr clock config", function() {
|
|
|
|
before(function() {
|
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_24hr.js";
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function (done) {
|
|
|
|
app.start().then(function() { done(); } );
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
|
|
|
app.stop().then(function() { done(); });
|
|
|
|
});
|
|
|
|
|
|
|
|
it("shows date with correct format", function () {
|
|
|
|
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
|
|
|
|
return app.client.waitUntilWindowLoaded()
|
2017-01-31 17:02:18 -03:00
|
|
|
.getText(".clock .date").should.eventually.match(dateRegex);
|
2017-01-31 10:37:03 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
it("shows time in 24hr format", function() {
|
|
|
|
const timeRegex = /^(?:2[0-3]|[01]\d):[0-5]\d[0-5]\d$/
|
|
|
|
return app.client.waitUntilWindowLoaded()
|
2017-01-31 17:02:18 -03:00
|
|
|
.getText(".clock .time").should.eventually.match(timeRegex);
|
2017-01-31 10:37:03 -08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("with default 12hr clock config", function() {
|
|
|
|
before(function() {
|
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_12hr.js";
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function (done) {
|
|
|
|
app.start().then(function() { done(); } );
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
|
|
|
app.stop().then(function() { done(); });
|
|
|
|
});
|
|
|
|
|
|
|
|
it("shows date with correct format", function () {
|
|
|
|
const dateRegex = /^(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}, \d{4}$/;
|
|
|
|
return app.client.waitUntilWindowLoaded()
|
2017-01-31 17:02:18 -03:00
|
|
|
.getText(".clock .date").should.eventually.match(dateRegex);
|
2017-01-31 10:37:03 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
it("shows time in 12hr format", function() {
|
2017-01-31 12:24:11 -08:00
|
|
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[ap]m$/;
|
2017-01-31 10:37:03 -08:00
|
|
|
return app.client.waitUntilWindowLoaded()
|
2017-01-31 17:02:18 -03:00
|
|
|
.getText(".clock .time").should.eventually.match(timeRegex);
|
2017-01-31 10:37:03 -08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("with showPeriodUpper config enabled", function() {
|
|
|
|
before(function() {
|
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showPeriodUpper.js";
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function (done) {
|
|
|
|
app.start().then(function() { done(); } );
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
|
|
|
app.stop().then(function() { done(); });
|
|
|
|
});
|
|
|
|
|
|
|
|
it("shows 12hr time with upper case AM/PM", function() {
|
2017-01-31 12:24:11 -08:00
|
|
|
const timeRegex = /^(?:1[0-2]|[1-9]):[0-5]\d[0-5]\d[AP]M$/;
|
2017-01-31 10:37:03 -08:00
|
|
|
return app.client.waitUntilWindowLoaded()
|
2017-01-31 17:02:18 -03:00
|
|
|
.getText(".clock .time").should.eventually.match(timeRegex);
|
2017-01-31 10:37:03 -08:00
|
|
|
});
|
|
|
|
});
|
2017-02-01 14:33:17 -03:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-03-28 22:02:30 +02:00
|
|
|
describe("with showWeek config enabled", function() {
|
|
|
|
before(function() {
|
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/clock/clock_showWeek.js";
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function (done) {
|
|
|
|
app.start().then(function() { done(); } );
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
|
|
|
app.stop().then(function() { done(); });
|
|
|
|
});
|
|
|
|
|
|
|
|
it("shows week with correct format", function() {
|
|
|
|
const weekRegex = /^Week [0-9]{1,2}$/;
|
|
|
|
return app.client.waitUntilWindowLoaded()
|
|
|
|
.getText(".clock .week").should.eventually.match(weekRegex);
|
|
|
|
});
|
2017-04-12 22:29:20 -03:00
|
|
|
|
|
|
|
it("shows week with correct number of week of year", function() {
|
2017-04-24 22:49:15 -03:00
|
|
|
|
|
|
|
it("FIXME: if the day is a sunday this not match");
|
|
|
|
// const currentWeekNumber = require("current-week-number")();
|
|
|
|
// const weekToShow = "Week " + currentWeekNumber;
|
|
|
|
// return app.client.waitUntilWindowLoaded()
|
|
|
|
// .getText(".clock .week").should.eventually.equal(weekToShow);
|
2017-04-12 22:29:20 -03:00
|
|
|
});
|
|
|
|
|
2017-03-28 22:02:30 +02:00
|
|
|
});
|
|
|
|
|
2017-01-31 10:37:03 -08:00
|
|
|
});
|