Skip to content

Commit

Permalink
test: add tests in YearGrid
Browse files Browse the repository at this point in the history
Signed-off-by: Rong Sen Ng (motss) <wes.ngrongsen@gmail.com>
  • Loading branch information
motss committed Feb 19, 2022
1 parent 62e76ac commit c32d892
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/__tests__/month-calendar/app-month-calendar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ describe(appMonthCalendarName, () => {
);
});

it('renders with correct title for selected today', async () => {
it('renders correct title for selected today', async () => {
const el = await fixture<AppMonthCalendar>(
html`<app-month-calendar .data=${data}></app-month-calendar>`
);
Expand Down Expand Up @@ -449,7 +449,7 @@ describe(appMonthCalendarName, () => {
] = a;

it(
messageFormatter('renders with correct title (selectedDateLabel=%s, todayDateLabel=%s)', a),
messageFormatter('renders correct title (selectedDateLabel=%s, todayDateLabel=%s)', a),
async () => {
const todayFullDate = new Date(data.todayDate);
const todayUTCDate = todayFullDate.getUTCDate();
Expand Down
26 changes: 25 additions & 1 deletion src/__tests__/year-grid/app-year-grid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,30 @@ describe(appYearGridName, () => {
]);
});

it('renders correct title for selected today year', async () => {
const todayDate = toResolvedDate();
const max = new Date(new Date(todayDate).setUTCFullYear(todayDate.getUTCFullYear() + 2));
const min = new Date(new Date(todayDate).setUTCFullYear(todayDate.getUTCFullYear() - 2));

const testData: YearGridData = {
...data,
date: todayDate,
max,
min,
};
const el = await fixture<AppYearGrid>(html`<app-year-grid .data=${testData}></app-year-grid>`);

const selectedYear = el.query<HTMLButtonElement>(elementSelectors.selectedYear);
const todayYear = el.query<HTMLButtonElement>(elementSelectors.todayYear);

expect(selectedYear).exist;
expect(todayYear).exist;
expect(selectedYear?.isEqualNode(todayYear)).true;

expect(selectedYear).attr('title', labelSelectedYear);
expect(todayYear).attr('title', labelSelectedYear);
});

type TestTitle = [
testSelectedYearLabel: string | undefined,
testTodayYearLabel: string | undefined,
Expand All @@ -203,7 +227,7 @@ describe(appYearGridName, () => {
] = a;

it(
messageFormatter('renders with correct title (selectedYearLabel=%s, todayYearLabel=%s)', a),
messageFormatter('renders correct title (selectedYearLabel=%s, todayYearLabel=%s)', a),
async () => {
const dataMax = new Date(data.max);
const dataMin = new Date(data.min);
Expand Down

0 comments on commit c32d892

Please sign in to comment.