mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
feat(demo): unit test the ngModel binding
This commit is contained in:
@ -29,4 +29,27 @@ describe('InputsTestPageComponent', () => {
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('testInputOne binding', () => {
|
||||
let input;
|
||||
beforeEach(
|
||||
fakeAsync(() => {
|
||||
component.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
tick();
|
||||
input = fixture.debugElement.query(By.css('#stdTextInput')).nativeElement;
|
||||
// This is what I ultimtely want to test...
|
||||
//
|
||||
// const ionInput = fixture.debugElement.query(By.css('#ionTextInput'));
|
||||
// input = ionInput.query(By.css('input')).nativeElement;
|
||||
})
|
||||
);
|
||||
|
||||
it('should reflect changes to the input', () => {
|
||||
expect(input).toBeTruthy();
|
||||
input.value = 'Frank';
|
||||
input.dispatchEvent(new Event('input'));
|
||||
expect(component.textValue).toEqual('Frank');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import { GroupInputsPageComponent } from './group-inputs-page.component';
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
|
||||
describe('GroupInputsPageComponent', () => {
|
||||
let component: GroupInputsPageComponent;
|
||||
@ -10,6 +12,7 @@ describe('GroupInputsPageComponent', () => {
|
||||
beforeEach(
|
||||
async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [FormsModule, SharedModule],
|
||||
declarations: [GroupInputsPageComponent],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
}).compileComponents();
|
||||
|
||||
Reference in New Issue
Block a user