2017-02-05 19:35:33 -03:00
|
|
|
const Application = require("spectron").Application;
|
|
|
|
const path = require("path");
|
|
|
|
const chai = require("chai");
|
2017-02-07 16:00:35 -03:00
|
|
|
const expect = chai.expect;
|
2017-02-05 19:35:33 -03:00
|
|
|
const chaiAsPromised = require("chai-as-promised");
|
|
|
|
|
|
|
|
var electronPath = path.join(__dirname, "../../../", "node_modules", ".bin", "electron");
|
|
|
|
|
|
|
|
if (process.platform === "win32") {
|
|
|
|
electronPath += ".cmd";
|
|
|
|
}
|
|
|
|
|
|
|
|
var appPath = path.join(__dirname, "../../../js/electron.js");
|
|
|
|
|
|
|
|
var app = new Application({
|
|
|
|
path: electronPath,
|
|
|
|
args: [appPath]
|
|
|
|
});
|
|
|
|
|
|
|
|
global.before(function () {
|
|
|
|
chai.should();
|
|
|
|
chai.use(chaiAsPromised);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("Compliments module", function () {
|
2017-02-12 15:36:18 -03:00
|
|
|
this.timeout(20000);
|
2017-02-05 19:35:33 -03:00
|
|
|
|
|
|
|
describe("parts of days", function() {
|
|
|
|
before(function() {
|
|
|
|
// Set config sample for use in test
|
|
|
|
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_parts_day.js";
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function (done) {
|
|
|
|
app.start().then(function() { done(); } );
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
|
|
|
app.stop().then(function() { done(); });
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-02-07 16:00:35 -03:00
|
|
|
it("if Morning compliments for that part of day", function () {
|
|
|
|
var 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
|
|
|
|
return app.client.waitUntilWindowLoaded()
|
|
|
|
.getText(".compliments").then(function (text) {
|
|
|
|
expect(text).to.be.oneOf(["Hi", "Good Morning", "Morning test"]);
|
|
|
|
})
|
2017-02-05 19:35:33 -03:00
|
|
|
}
|
2017-02-07 16:00:35 -03:00
|
|
|
});
|
|
|
|
|
|
|
|
it("if Afternoon show Compliments for that part of day", function () {
|
|
|
|
var hour = new Date().getHours();
|
|
|
|
if (hour >= 12 && hour < 17) {
|
|
|
|
// if morning check
|
|
|
|
return app.client.waitUntilWindowLoaded()
|
|
|
|
.getText(".compliments").then(function (text) {
|
|
|
|
expect(text).to.be.oneOf(["Hello", "Good Afternoon", "Afternoon test"]);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
2017-02-05 19:35:33 -03:00
|
|
|
|
2017-02-07 16:00:35 -03:00
|
|
|
it("if Evening show Compliments for that part of day", function () {
|
|
|
|
var hour = new Date().getHours();
|
|
|
|
if (!(hour >= 3 && hour < 12) && !(hour >= 12 && hour < 17)) {
|
|
|
|
// if evening check
|
|
|
|
return app.client.waitUntilWindowLoaded()
|
|
|
|
.getText(".compliments").then(function (text) {
|
|
|
|
expect(text).to.be.oneOf(["Hello There", "Good Evening", "Evening test"]);
|
|
|
|
})
|
|
|
|
}
|
2017-02-05 19:35:33 -03:00
|
|
|
});
|
2017-02-07 16:00:35 -03:00
|
|
|
|
2017-02-05 19:35:33 -03:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|