'Unit test in jasmine for elements window.history.forward
I need to cover this line with unit tests in angular, what would I need to cover this
app.component.ts
cantReturn() {
window.onpopstate = ()=> window.history.forward()
}
app.component.spec.ts
it('test function1', function () {
const spy = spyOn(window.history, 'forward' );
component.cantReturn()
expect(spy).toHaveBeenCalled();
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
