Created
March 9, 2019 12:36
-
-
Save t-palmer/329548ba36d2011e885e828da1b27c0a to your computer and use it in GitHub Desktop.
Example spec file for parent component for viewchild-unit-test-example
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
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |
import { ParentComponent } from './parent.component'; | |
import { ChildComponent } from '../child/child.component'; | |
describe('ParentComponent', () => { | |
let component: ParentComponent; | |
let fixture: ComponentFixture<ParentComponent>; | |
beforeEach(async(() => { | |
TestBed.configureTestingModule({ | |
declarations: [ | |
ParentComponent, | |
ChildComponent | |
] | |
}) | |
.compileComponents(); | |
})); | |
beforeEach(() => { | |
fixture = TestBed.createComponent(ParentComponent); | |
component = fixture.componentInstance; | |
fixture.detectChanges(); | |
}); | |
it('should create', () => { | |
expect(component).toBeTruthy(); | |
}); | |
it('should call updateTimeStamp', () => { | |
spyOn(component.childComponent, 'updateTimeStamp'); | |
component.update(); | |
expect(component.childComponent.updateTimeStamp).toHaveBeenCalled(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment