Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ba72526

Browse files
committed
test(state): re-add ngOnDestroy test
1 parent e2b90d3 commit ba72526

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

libs/state/src/lib/rx-state.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component } from '@angular/core';
22
import { TestBed } from '@angular/core/testing';
33
import { of } from 'rxjs';
44
import { RxStateSetupFn, rxState } from './rx-state';
5+
import { RxState } from './rx-state.service';
56

67
describe(rxState, () => {
78
it('should create rxState', () => {
@@ -87,13 +88,13 @@ describe(rxState, () => {
8788
});
8889
});
8990

90-
/*it('should call ngOnDestroy', () => {
91-
const { fixture, component } = setupComponent();
92-
const spy = jest.spyOn(component.state, 'ngOnDestroy');
93-
expect(spy).not.toHaveBeenCalled();
91+
it('should call ngOnDestroy', () => {
92+
RxState.prototype.ngOnDestroy = jest.fn();
93+
const { fixture } = setupComponent();
94+
expect(RxState.prototype.ngOnDestroy).not.toHaveBeenCalled();
9495
fixture.destroy();
95-
expect(spy).toHaveBeenCalled();
96-
});*/
96+
expect(RxState.prototype.ngOnDestroy).toHaveBeenCalled();
97+
});
9798
});
9899

99100
function setupComponent<State extends object>(setupFn?: RxStateSetupFn<State>) {

0 commit comments

Comments
 (0)