2017-07-24 22:08:12 +02:00
|
|
|
const helpers = require("../global-setup");
|
2017-02-05 19:35:33 -03:00
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("Compliments module", function () {
|
2017-07-24 22:08:12 +02:00
|
|
|
helpers.setupTimeout(this);
|
|
|
|
|
2021-03-20 20:37:45 +01:00
|
|
|
let app = null;
|
2017-02-20 05:25:16 -03:00
|
|
|
|
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-02-20 05:25:16 -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-02-20 05:25:16 -03:00
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("parts of days", function () {
|
2021-06-08 00:47:40 +02:00
|
|
|
beforeAll(function () {
|
2017-02-05 19:35:33 -03:00
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_parts_day.js";
|
|
|
|
});
|
|
|
|
|
2021-01-30 20:29:59 +01:00
|
|
|
it("if Morning compliments for that part of day", async function () {
|
2021-03-20 20:37:45 +01:00
|
|
|
const hour = new Date().getHours();
|
2017-02-05 19:35:33 -03:00
|
|
|
if (hour >= 3 && hour < 12) {
|
2017-02-07 16:00:35 -03:00
|
|
|
// if morning check
|
2021-01-30 20:29:59 +01:00
|
|
|
const elem = await app.client.$(".compliments");
|
|
|
|
return elem.getText(".compliments").then(function (text) {
|
2021-06-11 22:24:21 +02:00
|
|
|
expect(["Hi", "Good Morning", "Morning test"]).toContain(text);
|
2021-01-30 20:29:59 +01:00
|
|
|
});
|
2017-02-05 19:35:33 -03:00
|
|
|
}
|
2017-02-07 16:00:35 -03:00
|
|
|
});
|
|
|
|
|
2021-01-30 20:29:59 +01:00
|
|
|
it("if Afternoon show Compliments for that part of day", async function () {
|
2021-03-20 20:37:45 +01:00
|
|
|
const hour = new Date().getHours();
|
2017-02-07 16:00:35 -03:00
|
|
|
if (hour >= 12 && hour < 17) {
|
2021-03-20 20:37:45 +01:00
|
|
|
// if afternoon check
|
2021-01-30 20:29:59 +01:00
|
|
|
const elem = await app.client.$(".compliments");
|
|
|
|
return elem.getText(".compliments").then(function (text) {
|
2021-06-11 22:24:21 +02:00
|
|
|
expect(["Hello", "Good Afternoon", "Afternoon test"]).toContain(text);
|
2021-01-30 20:29:59 +01:00
|
|
|
});
|
2017-02-07 16:00:35 -03:00
|
|
|
}
|
|
|
|
});
|
2017-02-05 19:35:33 -03:00
|
|
|
|
2021-01-30 20:29:59 +01:00
|
|
|
it("if Evening show Compliments for that part of day", async function () {
|
2021-03-20 20:37:45 +01:00
|
|
|
const hour = new Date().getHours();
|
2017-02-07 16:00:35 -03:00
|
|
|
if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) {
|
|
|
|
// if evening check
|
2021-01-30 20:29:59 +01:00
|
|
|
const elem = await app.client.$(".compliments");
|
|
|
|
return elem.getText(".compliments").then(function (text) {
|
2021-06-11 22:24:21 +02:00
|
|
|
expect(["Hello There", "Good Evening", "Evening test"]).toContain(text);
|
2021-01-30 20:29:59 +01:00
|
|
|
});
|
2017-02-07 16:00:35 -03:00
|
|
|
}
|
2017-02-05 19:35:33 -03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("Feature anytime in compliments module", function () {
|
|
|
|
describe("Set anytime and empty compliments for morning, evening and afternoon ", function () {
|
2021-06-08 00:47:40 +02:00
|
|
|
beforeAll(function () {
|
2017-02-20 04:59:15 -03:00
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_anytime.js";
|
|
|
|
});
|
|
|
|
|
2021-01-30 20:29:59 +01:00
|
|
|
it("Show anytime because if configure empty parts of day compliments and set anytime compliments", async function () {
|
|
|
|
const elem = await app.client.$(".compliments");
|
|
|
|
return elem.getText(".compliments").then(function (text) {
|
2021-06-11 22:24:21 +02:00
|
|
|
expect(["Anytime here"]).toContain(text);
|
2021-01-30 20:29:59 +01:00
|
|
|
});
|
2017-02-20 04:59:15 -03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("Only anytime present in configuration compliments", function () {
|
2021-06-08 00:47:40 +02:00
|
|
|
beforeAll(function () {
|
2017-02-20 04:59:15 -03:00
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_only_anytime.js";
|
|
|
|
});
|
|
|
|
|
2021-01-30 20:29:59 +01:00
|
|
|
it("Show anytime compliments", async function () {
|
|
|
|
const elem = await app.client.$(".compliments");
|
|
|
|
return elem.getText(".compliments").then(function (text) {
|
2021-06-11 22:24:21 +02:00
|
|
|
expect(["Anytime here"]).toContain(text);
|
2021-01-30 20:29:59 +01:00
|
|
|
});
|
2017-02-20 04:59:15 -03:00
|
|
|
});
|
2017-02-18 23:38:39 -03:00
|
|
|
});
|
|
|
|
});
|
2020-03-14 21:14:45 +01:00
|
|
|
|
2020-05-11 22:22:32 +02:00
|
|
|
describe("Feature date in compliments module", function () {
|
|
|
|
describe("Set date and empty compliments for anytime, morning, evening and afternoon", function () {
|
2021-06-08 00:47:40 +02:00
|
|
|
beforeAll(function () {
|
2020-03-14 21:14:45 +01:00
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_date.js";
|
|
|
|
});
|
|
|
|
|
2021-01-30 20:29:59 +01:00
|
|
|
it("Show happy new year compliment on new years day", async function () {
|
|
|
|
const elem = await app.client.$(".compliments");
|
|
|
|
return elem.getText(".compliments").then(function (text) {
|
2021-06-11 22:24:21 +02:00
|
|
|
expect(["Happy new year!"]).toContain(text);
|
2021-01-30 20:29:59 +01:00
|
|
|
});
|
2020-03-14 21:14:45 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-02-05 19:35:33 -03:00
|
|
|
});
|