/
basic-inputs-page.component.spec.ts
55 lines (48 loc) · 1.7 KB
/
basic-inputs-page.component.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { IonicAngularModule } from '@ionic/angular';
import { BasicInputsPageComponent } from './basic-inputs-page.component';
describe('InputsTestPageComponent', () => {
let component: BasicInputsPageComponent;
let fixture: ComponentFixture<BasicInputsPageComponent>;
beforeEach(
async(() => {
TestBed.configureTestingModule({
declarations: [BasicInputsPageComponent],
imports: [FormsModule, IonicAngularModule.forRoot()],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
}).compileComponents();
})
);
beforeEach(() => {
fixture = TestBed.createComponent(BasicInputsPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
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');
});
});
});