diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js index 7b2fa74a..14ad67dc 100644 --- a/modules/default/compliments/compliments.js +++ b/modules/default/compliments/compliments.js @@ -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; diff --git a/tests/configs/modules/compliments/compliments_date.js b/tests/configs/modules/compliments/compliments_date.js index 04acdde4..649d789b 100644 --- a/tests/configs/modules/compliments/compliments_date.js +++ b/tests/configs/modules/compliments/compliments_date.js @@ -27,8 +27,8 @@ let config = { morning: [], afternoon: [], evening: [], - 1012: [ - "Happy birthday, Ada Lovelace!" + "....-01-01": [ + "Happy new year!" ] } } diff --git a/tests/e2e/modules/compliments_spec.js b/tests/e2e/modules/compliments_spec.js index 2ebd2e82..d7828268 100644 --- a/tests/e2e/modules/compliments_spec.js +++ b/tests/e2e/modules/compliments_spec.js @@ -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!"]); }); });