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.
fix(input): issue where undefined values would be displayed
- add behavior test to verify
- Loading branch information
1 parent
46dd541
commit 294c073
Showing
2 changed files
with
87 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,88 @@ | ||
import {componentSanityCheck} from "../../util"; | ||
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 {MdInput,MdInputContainer} from "../../../ng2-material/components/input/input"; | ||
import {TimerWrapper} from "angular2/src/facade/async"; | ||
import {findChildByAttribute} from "../../util"; | ||
|
||
|
||
export function main() { | ||
|
||
let template = `<md-input-container><input md-input type="text"></md-input-container>`; | ||
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<IInputFixture> { | ||
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(); | ||
}); | ||
})); | ||
}); | ||
}); | ||
|
||
|
||
} | ||
|