X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Flib%2Ftemplate-helper.js;h=fa3f86a33a7517bbdee59626cc6de2f92218ac55;hb=826ef55e1f8506012d627294c8225cf8b01a5a69;hp=c0cd94851343de6a757fd7912ed85b72b7a4a6c7;hpb=2a4abfad091846a4fa528b44a31962c5150e6b0a;p=squeep-html-template-helper diff --git a/test/lib/template-helper.js b/test/lib/template-helper.js index c0cd948..fa3f86a 100644 --- a/test/lib/template-helper.js +++ b/test/lib/template-helper.js @@ -56,6 +56,11 @@ describe('Template Helper', function () { const result = th.dateFormat(undefined, undefined, undefined, expected); assert.strictEqual(result, expected); }); + it('handles invalid date', function () { + const expected = 'otherwise'; + const result = th.dateFormat(new Date('bad date'), undefined, undefined, expected); + assert.strictEqual(result, expected); + }); it('renders Infinity', function () { const expected = 'end of time'; const result = th.dateFormat(Infinity, expected); @@ -78,6 +83,26 @@ describe('Template Helper', function () { }); }); // dateFormat + describe('timeElement', function () { + it('renders a date', function () { + const when = new Date('2022-09-11T21:17:56.872Z'); + const expected = ''; + const result = th.timeElement(when); + assert.strictEqual(result, expected); + }); + it('covers title', function () { + const when = new Date('2022-09-11T21:17:56.872Z'); + const expected = ''; + const result = th.timeElement(when, { title: 'a date' }); + assert.strictEqual(result, expected); + }); + it('covers other', function () { + const expected = ''; + const result = th.timeElement(1648420085049); + assert.strictEqual(result, expected); + }); + }); // timeElement + describe('secondsToPeriod', function () { it('covers seconds', function () { const result = th.secondsToPeriod(45); @@ -166,6 +191,13 @@ describe('Template Helper', function () { }); }); // LI + describe('indented', function () { + it('covers', function () { + const result = th.indented(2, ['foo', 'bar']); + result.forEach((r) => assert(r.startsWith('\t\t'))); + }); + }); // indented + describe('htmlBody', function () { it('covers no main', function () { const result = th.htmlBody(pagePathLevel, ctx, options);