|
|
|
@ -29,57 +29,35 @@ export class TestComponent extends AbstractNgModelComponent implements OnInit { |
|
|
|
} |
|
|
|
|
|
|
|
describe('AbstractNgModelComponent', () => { |
|
|
|
let spectator: SpectatorHost<TestComponent>; |
|
|
|
let spectator: SpectatorHost<TestComponent, { val: any; override: boolean }>; |
|
|
|
|
|
|
|
const createHost = createHostFactory({ |
|
|
|
component: TestComponent, |
|
|
|
declarations: [AbstractNgModelComponent], |
|
|
|
imports: [FormsModule], |
|
|
|
detectChanges: false, |
|
|
|
}); |
|
|
|
|
|
|
|
test('should pass the value with ngModel', done => { |
|
|
|
spectator = createHost('<abp-test [(ngModel)]="val"></abp-test>', { |
|
|
|
beforeEach(() => { |
|
|
|
spectator = createHost('<abp-test [(ngModel)]="val" [override]="override"></abp-test>', { |
|
|
|
hostProps: { |
|
|
|
val: '1', |
|
|
|
override: false, |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
spectator.detectChanges(); |
|
|
|
|
|
|
|
timer(0).subscribe(() => { |
|
|
|
expect(spectator.component.value).toBe('1'); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
test.skip('should set the value with ngModel', done => { |
|
|
|
spectator = createHost('<abp-test [(ngModel)]="val" [override]="true"></abp-test>', { |
|
|
|
hostProps: { |
|
|
|
val: '2', |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
spectator.detectChanges(); |
|
|
|
|
|
|
|
test('should pass the value with ngModel', done => { |
|
|
|
timer(0).subscribe(() => { |
|
|
|
expect(spectator.hostComponent['val']).toBe('test'); |
|
|
|
expect(spectator.component.value).toBe('1'); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
test.skip('should not change value when disable is true', done => { |
|
|
|
spectator = createHost('<abp-test [(ngModel)]="val" [disabled]="true"></abp-test>', { |
|
|
|
hostProps: { |
|
|
|
val: '2', |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
spectator.component['val'] = '3'; |
|
|
|
spectator.detectChanges(); |
|
|
|
test('should set the value with ngModel', done => { |
|
|
|
spectator.setHostInput({ val: '2', override: true }); |
|
|
|
|
|
|
|
timer(0).subscribe(() => { |
|
|
|
expect(spectator.hostComponent['val']).toBe('2'); |
|
|
|
expect(spectator.hostComponent.val).toBe('test'); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|