Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(toolbar): add toolbar role to host element #2914

Merged
merged 1 commit into from
Feb 6, 2017
Merged
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
21 changes: 16 additions & 5 deletions src/lib/toolbar/toolbar.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import {Component} from '@angular/core';
import {TestBed, async} from '@angular/core/testing';
import {TestBed, async, ComponentFixture} from '@angular/core/testing';
import {By} from '@angular/platform-browser';
import {MdToolbarModule} from './toolbar';


describe('MdToolbar', () => {

let fixture: ComponentFixture<TestApp>;
let testComponent: TestApp;
let toolbarElement: HTMLElement;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [MdToolbarModule.forRoot()],
Expand All @@ -15,11 +19,13 @@ describe('MdToolbar', () => {
TestBed.compileComponents();
}));

it('should apply class based on color attribute', () => {
let fixture = TestBed.createComponent(TestApp);
let testComponent = fixture.debugElement.componentInstance;
let toolbarElement = fixture.debugElement.query(By.css('md-toolbar')).nativeElement;
beforeEach(() => {
fixture = TestBed.createComponent(TestApp);
testComponent = fixture.debugElement.componentInstance;
toolbarElement = fixture.debugElement.query(By.css('md-toolbar')).nativeElement;
});

it('should apply class based on color attribute', () => {
testComponent.toolbarColor = 'primary';
fixture.detectChanges();

Expand All @@ -37,6 +43,11 @@ describe('MdToolbar', () => {
expect(toolbarElement.classList.contains('md-accent')).toBe(false);
expect(toolbarElement.classList.contains('md-warn')).toBe(true);
});

it('should set the toolbar role on the host', () => {
expect(toolbarElement.getAttribute('role')).toBe('toolbar');
});

});


Expand Down
3 changes: 3 additions & 0 deletions src/lib/toolbar/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export class MdToolbarRow {}
selector: 'md-toolbar, mat-toolbar',
templateUrl: 'toolbar.html',
styleUrls: ['toolbar.css'],
host: {
role: 'toolbar'
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
})
Expand Down