diff --git a/ng2-material/components/input/input.ts b/ng2-material/components/input/input.ts index 2976ebed..8da7f009 100644 --- a/ng2-material/components/input/input.ts +++ b/ng2-material/components/input/input.ts @@ -10,6 +10,7 @@ import {Input,Output} from 'angular2/core'; import {isPresent} from 'angular2/src/facade/lang'; import {DOM} from "angular2/src/platform/dom/dom_adapter"; import {TimerWrapper} from "angular2/src/facade/async"; +import {isBlank} from "angular2/src/facade/lang"; // TODO(jd): `; componentSanityCheck('Input Container', 'md-input-container', template); - componentSanityCheck('Input', 'input[md-input]', template); + + interface IInputFixture { + fixture:ComponentFixture; + input:MdInput; + container:MdInputContainer; + inputDebug:DebugElement; + containerDebug:DebugElement; + } + + @Component({selector: 'test-app'}) + @View({ + directives: [MdInput, MdInputContainer], + template: template + }) + class TestComponent { + } + + describe('Input', () => { + let builder: TestComponentBuilder; + + function setup(template: string = null): Promise { + let prep = template === null ? + builder.createAsync(TestComponent) : + builder.overrideTemplate(TestComponent, template).createAsync(TestComponent); + return prep.then((fixture: ComponentFixture) => { + fixture.detectChanges(); + let input = findChildByAttribute(fixture.debugElement, 'md-input'); + let container = findChildByTag(fixture.debugElement, 'md-input-container'); + return { + fixture: fixture, + input: input.componentInstance, + container: container.componentInstance, + inputDebug: input, + containerDebug: container, + }; + }).catch(console.error.bind(console)); + } + + beforeEachProviders(() => [ + MATERIAL_PROVIDERS, + provide(UrlResolver, {useValue: new TestUrlResolver()}), + ]); + beforeEach(inject([TestComponentBuilder], (tcb) => { + builder = tcb; + })); + + describe('input[md-input]', () => { + it('should initialize with empty string value', inject([AsyncTestCompleter], (async) => { + setup().then((api: IInputFixture) => { + api.fixture.destroy(); + expect(api.input.value).toBe(''); + async.done(); + }); + })); + }); + }); + + }