diff --git a/helpers/moment.js b/helpers/moment.js index 86b17bd..4d2afed 100644 --- a/helpers/moment.js +++ b/helpers/moment.js @@ -43,6 +43,7 @@ const factory = () => { return moment(chrono.parseDate(str)).format(pattern); } + // If handlebars, expose moment methods as hash properties if (options && options.hash) { if (options.context) { @@ -55,7 +56,7 @@ const factory = () => { if (Object.keys(moment.prototype).indexOf(key) !== -1 && typeof res[key] === 'function') { return res[key](options.hash[key]); } else { - console.error('moment.js does not support "' + key + '"'); + console.warn('moment.js does not support "' + key + '"'); } } } diff --git a/spec/helpers/moment.js b/spec/helpers/moment.js index 24790d7..55c8100 100644 --- a/spec/helpers/moment.js +++ b/spec/helpers/moment.js @@ -1,8 +1,13 @@ +const Sinon = require('sinon'); const Lab = require('lab'), lab = exports.lab = Lab.script(), describe = lab.experiment, it = lab.it, + beforeEach = lab.beforeEach, + afterEach = lab.afterEach, testRunner = require('../spec-helpers').testRunner; +const Code = require('code'), + expect = Code.expect; const moment = require('moment'); describe('moment helper', function () { @@ -67,4 +72,31 @@ describe('moment helper', function () { } ], done); }); + + describe('when amount is provided', () => { + let consoleWarnCopy = console.warn; + + beforeEach(done => { + console.warn = Sinon.fake(); + done(); + }); + + afterEach(done => { + console.warn = consoleWarnCopy; + done(); + }); + + it('runs console.warn', (done) => { + runTestCases([ + { + input: `{{moment "2022-01-01" isAfter="1999-12-31" amount=1}}`, + output: `true`, + } + ], () => { + expect(console.warn.called).to.equal(true); + done(); + }); + + }); + }); }); \ No newline at end of file