|
| 1 | +import {Component} from 'angular2/core'; |
| 2 | +import { |
| 3 | + inject, |
| 4 | + TestComponentBuilder |
| 5 | +} from 'angular2/testing'; |
| 6 | + |
| 7 | +import { |
| 8 | + it, |
| 9 | + iit, |
| 10 | + describe, |
| 11 | + ddescribe, |
| 12 | + expect, |
| 13 | + beforeEach, |
| 14 | +} from '../../core/facade/testing'; |
| 15 | +import {By} from 'angular2/platform/browser'; |
| 16 | +import {MdToolbar} from './toolbar'; |
| 17 | + |
| 18 | +export function main() { |
| 19 | + describe('MdToolbar', () => { |
| 20 | + let builder: TestComponentBuilder; |
| 21 | + |
| 22 | + beforeEach(inject([TestComponentBuilder], (tcb: TestComponentBuilder) => { |
| 23 | + builder = tcb; |
| 24 | + })); |
| 25 | + |
| 26 | + it('should apply class based on color attribute', (done: () => void) => { |
| 27 | + return builder.createAsync(TestApp).then((fixture) => { |
| 28 | + let testComponent = fixture.debugElement.componentInstance; |
| 29 | + let toolbarDebugElement = fixture.debugElement.query(By.css('md-toolbar')); |
| 30 | + |
| 31 | + testComponent.toolbarColor = 'primary'; |
| 32 | + fixture.detectChanges(); |
| 33 | + |
| 34 | + expect(toolbarDebugElement.nativeElement.classList.contains('md-primary')).toBe(true); |
| 35 | + |
| 36 | + testComponent.toolbarColor = 'accent'; |
| 37 | + fixture.detectChanges(); |
| 38 | + |
| 39 | + expect(toolbarDebugElement.nativeElement.classList.contains('md-accent')).toBe(true); |
| 40 | + |
| 41 | + testComponent.toolbarColor = 'warn'; |
| 42 | + fixture.detectChanges(); |
| 43 | + |
| 44 | + expect(toolbarDebugElement.nativeElement.classList.contains('md-warn')).toBe(true); |
| 45 | + |
| 46 | + done(); |
| 47 | + }); |
| 48 | + }); |
| 49 | + |
| 50 | + }); |
| 51 | +} |
| 52 | + |
| 53 | +@Component({ |
| 54 | + selector: 'test-app', |
| 55 | + template: ` |
| 56 | + <md-toolbar [color]="toolbarColor"> |
| 57 | + <span>Test Toolbar</span> |
| 58 | + </md-toolbar> |
| 59 | + `, |
| 60 | + directives: [MdToolbar] |
| 61 | +}) |
| 62 | +class TestApp { |
| 63 | + toolbarColor: string; |
| 64 | +} |
0 commit comments