X-Git-Url: http://git.squeep.com/?p=squeep-html-template-helper;a=blobdiff_plain;f=test%2Flib%2Ftemplate-helper.js;h=c0cd94851343de6a757fd7912ed85b72b7a4a6c7;hp=29878cd4e29e638ba1c9bdde5d500a1fad87dd11;hb=2a4abfad091846a4fa528b44a31962c5150e6b0a;hpb=f8d8a0142eaf713a9258c4f5738cdcb6b6e5c7bd diff --git a/test/lib/template-helper.js b/test/lib/template-helper.js index 29878cd..c0cd948 100644 --- a/test/lib/template-helper.js +++ b/test/lib/template-helper.js @@ -50,6 +50,34 @@ describe('Template Helper', function () { }); }); // dateOrNot + describe('dateFormat', function () { + it('renders otherwise', function () { + const expected = 'otherwise'; + const result = th.dateFormat(undefined, undefined, undefined, expected); + assert.strictEqual(result, expected); + }); + it('renders Infinity', function () { + const expected = 'end of time'; + const result = th.dateFormat(Infinity, expected); + assert.strictEqual(result, expected); + }); + it('renders -Infinity', function () { + const expected = 'beginning of time'; + const result = th.dateFormat(-Infinity, undefined, expected); + assert.strictEqual(result, expected); + }); + it('renders a Date', function () { + const expected = 'Mar 27, 2022, 3:28:05 PM PDT'; + const result = th.dateFormat(new Date('2022-03-27T22:28:05.049Z')); + assert.strictEqual(result, expected); + }); + it('renders a timestamp', function () { + const expected = 'Mar 27, 2022, 3:28:05 PM PDT'; + const result = th.dateFormat(1648420085049); + assert.strictEqual(result, expected); + }); + }); // dateFormat + describe('secondsToPeriod', function () { it('covers seconds', function () { const result = th.secondsToPeriod(45);