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

Skip to content

Commit 2656a70

Browse files
committed
test(state): fix action tests
1 parent 9d582a7 commit 2656a70

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

libs/state/actions/src/lib/actions.factory.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// eslint-disable-next-line @nx/enforce-module-boundaries
2-
import { mockConsole } from '@test-helpers';
2+
import { mockConsole } from '@test-helpers/rx-angular';
33
import { RxActionFactory } from './actions.factory';
44
import { isObservable } from 'rxjs';
55
import { Component, ErrorHandler } from '@angular/core';

libs/state/actions/src/lib/actions.factory.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ErrorHandler, inject, Injectable, OnDestroy } from '@angular/core';
1+
import { ErrorHandler, Injectable, OnDestroy, Optional } from '@angular/core';
22
import { Subject } from 'rxjs';
33
import { actionProxyHandler } from './proxy';
44
import { Actions, ActionTransforms, EffectMap, RxActions } from './types';
@@ -23,9 +23,10 @@ type SubjectMap<T> = { [K in keyof T]: Subject<T[K]> };
2323
*/
2424
@Injectable()
2525
export class RxActionFactory<T extends Partial<Actions>> implements OnDestroy {
26-
private readonly errorHandler = inject(ErrorHandler, { optional: true });
2726
private subjects: SubjectMap<T>[] = [] as SubjectMap<T>[];
2827

28+
constructor(@Optional() private readonly errorHandler?: ErrorHandler) {}
29+
2930
/*
3031
* Returns a object based off of the provided typing with a separate setter `[prop](value: T[K]): void` and observable stream `[prop]$: Observable<T[K]>`;
3132
*

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { tap } from 'rxjs/operators';
12
import { rxActions } from './rx-actions';
23
import { debounceTime, isObservable } from 'rxjs';
34
import { Component, ErrorHandler, Provider } from '@angular/core';
@@ -99,12 +100,13 @@ describe('actions fn', () => {
99100
it('should apply behaviour to trigger', () => {
100101
const { component } = setupComponent<Actions>();
101102
const t = { se: () => void 0 };
102-
const dummyBehaviour = (o$) => o$.pipe(debounceTime(30));
103+
const spyBehavior = jest.fn();
104+
const dummyBehaviour = (o$) => o$.pipe(tap(spyBehavior));
103105
const spyT = jest.fn((_: any) => void 0);
104106

105107
const sub = component.actions.onProp(dummyBehaviour, spyT);
106108
component.actions.prop('p');
107-
expect(5).toBe(6);
109+
expect(spyBehavior).toHaveBeenCalledTimes(1);
108110
});
109111

110112
it('should not trigger side effect after unsubscribed', () => {

0 commit comments

Comments
 (0)