mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Implement suggestions from Michael
This commit is contained in:
parent
4e4d3418b3
commit
ff7dc95e93
@ -29,11 +29,14 @@ Module.register("compliments", {
|
||||
"You look nice!",
|
||||
"Hi, sexy!"
|
||||
],
|
||||
1403 : [
|
||||
"Happy birthday, Albert Einstein!"
|
||||
"....-01-01": [
|
||||
"Happy new year!"
|
||||
],
|
||||
1012: [
|
||||
"Happy birthday, Ada Lovelace!"
|
||||
"....-..-14": [
|
||||
"Have a great 14th day of the month!"
|
||||
],
|
||||
"2020-12-10": [
|
||||
"Happy 205th Birthday, Ada Lovelace!"
|
||||
]
|
||||
},
|
||||
updateInterval: 30000,
|
||||
@ -108,7 +111,7 @@ Module.register("compliments", {
|
||||
*/
|
||||
complimentArray: function() {
|
||||
var hour = moment().hour();
|
||||
var date = moment().format("DDMM");
|
||||
var date = moment().format("YYYY-MM-DD");
|
||||
var compliments;
|
||||
|
||||
if (hour >= this.config.morningStartTime && hour < this.config.morningEndTime && this.config.compliments.hasOwnProperty("morning")) {
|
||||
@ -129,8 +132,10 @@ Module.register("compliments", {
|
||||
|
||||
compliments.push.apply(compliments, this.config.compliments.anytime);
|
||||
|
||||
if (date in this.config.compliments) {
|
||||
compliments.push.apply(compliments, this.config.compliments[date]);
|
||||
for (entry in this.config.compliments) {
|
||||
if (new RegExp(entry).test(date)) {
|
||||
compliments.push.apply(compliments, this.config.compliments[entry]);
|
||||
}
|
||||
}
|
||||
|
||||
return compliments;
|
||||
|
@ -27,8 +27,8 @@ let config = {
|
||||
morning: [],
|
||||
afternoon: [],
|
||||
evening: [],
|
||||
1012: [
|
||||
"Happy birthday, Ada Lovelace!"
|
||||
"....-01-01": [
|
||||
"Happy new year!"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -96,12 +96,12 @@ describe("Compliments module", function() {
|
||||
before(function() {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/compliments/compliments_date.js";
|
||||
MockDate.set("2000-12-10");
|
||||
MockDate.set("2000-01-01");
|
||||
});
|
||||
|
||||
it("Show happy birthday compliment on special date", function() {
|
||||
it("Show happy new year compliment on new years day", function() {
|
||||
return app.client.waitUntilWindowLoaded().getText(".compliments").then(function(text) {
|
||||
expect(text).to.be.oneOf(["Happy birthday, Ada Lovelace!"]);
|
||||
expect(text).to.be.oneOf(["Happy new year!"]);
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user