Skip to content

Commit b10dcdf

Browse files
Step 3; introduce setInput in TestHostComponent to have 2 test inputs
1 parent df60b97 commit b10dcdf

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

src/app/component-under-test/component-under-test.component.spec.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,28 @@ describe('ComponentUnderTestComponent', () => {
1717
beforeEach(() => {
1818
testHostFixture = TestBed.createComponent(TestHostComponent);
1919
testHostComponent = testHostFixture.componentInstance;
20-
testHostFixture.detectChanges();
21-
});
22-
23-
it('should be created', () => {
24-
expect(testHostComponent).toBeTruthy();
2520
});
2621

2722
it('should show TEST INPUT', () => {
23+
testHostComponent.setInput('test input');
24+
testHostFixture.detectChanges();
2825
expect(testHostFixture.nativeElement.querySelector('div').innerText).toEqual('TEST INPUT');
2926
});
3027

28+
it('should show DIFFERENT TEST INPUT', () => {
29+
testHostComponent.setInput('different test input');
30+
testHostFixture.detectChanges();
31+
expect(testHostFixture.nativeElement.querySelector('div').innerText).toEqual('DIFFERENT TEST INPUT');
32+
});
3133
@Component({
3234
selector: `host-component`,
33-
template: `<component-under-test input="test input"></component-under-test>`
35+
template: `<component-under-test [input]="input"></component-under-test>`
3436
})
3537
class TestHostComponent {
38+
private input: string;
39+
40+
setInput(newInput: string) {
41+
this.input = newInput;
42+
}
3643
}
3744
});

0 commit comments

Comments
 (0)