Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/material/datepicker/calendar-body.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
[style.paddingTop]="_cellPadding"
[style.paddingBottom]="_cellPadding">
<div class="mat-calendar-body-cell-content"
role="button"
[class.mat-calendar-body-selected]="selectedValue === item.value"
[class.mat-calendar-body-today]="todayValue === item.value">
{{item.displayValue}}
Expand Down
13 changes: 11 additions & 2 deletions src/material/datepicker/calendar-body.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {Component} from '@angular/core';
import {Component, DebugElement} from '@angular/core';
import {MatCalendarBody, MatCalendarCell, MatCalendarCellCssClasses} from './calendar-body';
import {By} from '@angular/platform-browser';

Expand All @@ -21,6 +21,7 @@ describe('MatCalendarBody', () => {
describe('standard calendar body', () => {
let fixture: ComponentFixture<StandardCalendarBody>;
let testComponent: StandardCalendarBody;
let calendarBodyDebugElement: DebugElement;
let calendarBodyNativeElement: Element;
let rowEls: Element[];
let labelEls: Element[];
Expand All @@ -36,7 +37,7 @@ describe('MatCalendarBody', () => {
fixture = TestBed.createComponent(StandardCalendarBody);
fixture.detectChanges();

const calendarBodyDebugElement = fixture.debugElement.query(By.directive(MatCalendarBody));
calendarBodyDebugElement = fixture.debugElement.query(By.directive(MatCalendarBody));
calendarBodyNativeElement = calendarBodyDebugElement.nativeElement;
testComponent = fixture.componentInstance;

Expand All @@ -49,6 +50,14 @@ describe('MatCalendarBody', () => {
expect(cellEls.length).toBe(14);
});

it('sets all mat-calendar-body-cell-content role attribute to button', () => {
const contentCells = calendarBodyDebugElement
.queryAll(By.css('.mat-calendar-body-cell-content'))
.map(button => button.nativeElement);
expect(contentCells.every((button: any) => button.getAttribute('role') === 'button'))
.toBe(true, 'to see role="button" on every element');
});

it('highlights today', () => {
const todayCell = calendarBodyNativeElement.querySelector('.mat-calendar-body-today')!;
expect(todayCell).not.toBeNull();
Expand Down