This repository has been archived by the owner on Feb 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(toolbar): basic component initialization and option tests
BREAKING CHANGE: `<md-toolbar md-scroll-shrink>` has become `<md-toolbar mdScrollShrink>`
- Loading branch information
1 parent
b445f1a
commit a042725
Showing
3 changed files
with
121 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { | ||
AsyncTestCompleter, | ||
TestComponentBuilder, | ||
beforeEach, | ||
beforeEachProviders, | ||
describe, | ||
expect, | ||
inject, | ||
it, | ||
} from 'angular2/testing_internal'; | ||
import {DebugElement} from 'angular2/src/core/debug/debug_element'; | ||
import {Component, View, provide} from 'angular2/core'; | ||
import {UrlResolver} from 'angular2/compiler'; | ||
import {TestUrlResolver} from '../../test_url_resolver'; | ||
import {MATERIAL_PROVIDERS} from '../../../ng2-material/all'; | ||
import {ComponentFixture} from "angular2/testing"; | ||
import {findChildByTag} from "../../util"; | ||
import {findChildById} from "../../util"; | ||
import {MdToolbar} from "../../../ng2-material/components/toolbar/toolbar"; | ||
import {DOM} from "angular2/src/platform/dom/dom_adapter"; | ||
|
||
|
||
export function main() { | ||
|
||
@Component({selector: 'test-app'}) | ||
@View({ | ||
directives: [MdToolbar], | ||
template: `<md-toolbar></md-toolbar>` | ||
}) | ||
class TestComponent { | ||
} | ||
|
||
describe('Toolbar', () => { | ||
let builder: TestComponentBuilder; | ||
|
||
function setup(template: string = null, typeFn: any = TestComponent): Promise<ComponentFixture> { | ||
return template ? | ||
builder.overrideTemplate(typeFn, template).createAsync(typeFn) : | ||
builder.createAsync(typeFn); | ||
} | ||
|
||
beforeEachProviders(() => [ | ||
MATERIAL_PROVIDERS, | ||
provide(UrlResolver, {useValue: new TestUrlResolver()}), | ||
]); | ||
beforeEach(inject([TestComponentBuilder], (tcb) => { | ||
builder = tcb; | ||
})); | ||
|
||
describe('md-toolbar', () => { | ||
it('defaults mdScrollShrink to false', inject([AsyncTestCompleter], (async) => { | ||
setup().then((fixture: ComponentFixture) => { | ||
fixture.detectChanges(); | ||
let toolbar = <MdToolbar>findChildByTag(fixture.debugElement, 'md-toolbar').componentInstance; | ||
expect(toolbar.mdScrollShrink).toBe(false); | ||
async.done(); | ||
}); | ||
})); | ||
it('supports scroll shrink', inject([AsyncTestCompleter], (async) => { | ||
let template = ` | ||
<md-content> | ||
<md-toolbar mdScrollShrink></md-toolbar> | ||
<md-content></md-content> | ||
</md-content>`; | ||
setup(template).then((fixture: ComponentFixture) => { | ||
fixture.detectChanges(); | ||
let toolbar = <MdToolbar>findChildByTag(fixture.debugElement, 'md-toolbar').componentInstance; | ||
expect(toolbar.mdScrollShrink).toBe(true); | ||
async.done(); | ||
}); | ||
})); | ||
}); | ||
|
||
}); | ||
|
||
|
||
} | ||
|