From 91a9af23468fcc0c466278a332dc0bb3c4b3f226 Mon Sep 17 00:00:00 2001 From: ovidiu Date: Fri, 3 Jan 2020 23:27:12 +0200 Subject: [PATCH] chore(#433): more tests & remove as much logic as possible form template --- packages/calendar/src/LionCalendar.js | 6 +- packages/calendar/src/utils/createDay.js | 3 + packages/calendar/src/utils/dayTemplate.js | 6 +- packages/calendar/test/lion-calendar.test.js | 63 +++++++++++++++---- .../calendar/test/utils/dayTemplate.test.js | 2 +- 5 files changed, 64 insertions(+), 16 deletions(-) diff --git a/packages/calendar/src/LionCalendar.js b/packages/calendar/src/LionCalendar.js index 22603d1a3..af212983a 100644 --- a/packages/calendar/src/LionCalendar.js +++ b/packages/calendar/src/LionCalendar.js @@ -321,7 +321,8 @@ export class LionCalendar extends LocalizeMixin(LitElement) { } __renderNextButton(nextMonth, nextYear) { - const nextButtonTitle = `Next Month, ${nextMonth} ${nextYear}`; + const nextButtonTitle = `${this.msgLit('lion-calendar:nextMonth')}, ${nextMonth} ${nextYear}`; + return html` + `); }); }); @@ -588,10 +588,10 @@ describe('', () => { 'Previous month, November 2000', ); expect(elObj.nextMonthButtonEl.getAttribute('title')).to.equal( - 'Next Month, January 2001', + 'Next month, January 2001', ); expect(elObj.nextMonthButtonEl.getAttribute('aria-label')).to.equal( - 'Next Month, January 2001', + 'Next month, January 2001', ); }); }); @@ -1186,21 +1186,62 @@ describe('', () => { const elObj = new CalendarObject(el); expect(elObj.nextMonthButtonEl.getAttribute('aria-label')).to.equal( - 'Next Month, December 2019', + 'Next month, December 2019', ); + expect(elObj.previousMonthButtonEl.getAttribute('aria-label')).to.equal( + 'Previous month, October 2019', + ); + + expect(elObj.weekdayHeaderEls.map(h => h.getAttribute('aria-label'))).to.eql([ + 'Sunday', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday', + ]); + + expect(elObj.weekdayHeaderEls.map(h => h.textContent.trim())).to.deep.equal([ + 'Sun', + 'Mon', + 'Tue', + 'Wed', + 'Thu', + 'Fri', + 'Sat', + ]); + localize.locale = 'nl-NL'; await el.updateComplete; expect(elObj.nextMonthButtonEl.getAttribute('aria-label')).to.equal( - 'Next Month, december 2019', + 'Volgende maand, december 2019', ); - /** - * TODO: add more tests, e.g. for: - * - weekdays - * - weekday abbreviations - * - month names - */ + expect(elObj.previousMonthButtonEl.getAttribute('aria-label')).to.equal( + 'Vorige maand, oktober 2019', + ); + + expect(elObj.weekdayHeaderEls.map(h => h.getAttribute('aria-label'))).to.eql([ + 'zondag', + 'maandag', + 'dinsdag', + 'woensdag', + 'donderdag', + 'vrijdag', + 'zaterdag', + ]); + + expect(elObj.weekdayHeaderEls.map(h => h.textContent.trim())).to.deep.equal([ + 'zo', + 'ma', + 'di', + 'wo', + 'do', + 'vr', + 'za', + ]); }); }); diff --git a/packages/calendar/test/utils/dayTemplate.test.js b/packages/calendar/test/utils/dayTemplate.test.js index a33685ce1..bcf38386d 100644 --- a/packages/calendar/test/utils/dayTemplate.test.js +++ b/packages/calendar/test/utils/dayTemplate.test.js @@ -16,9 +16,9 @@ describe('dayTemplate', () => {