How to use the @ngrx/effects.Actions function in @ngrx/effects

To help you get started, we’ve selected a few @ngrx/effects examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github opfab / operatorfabric-core / ui / main / src / app / store / effects / translate.effects.spec.ts View on Github external
'publisher with a version already cached in the store', () => {

        // use the default test Publisher: "testPublisher" with 1 as publisherVersion
        const cachedPublisherAndVersion = generateThirdWithVersion('testPublisher', new Set(['1']));
        const cachedI18n$ = hot('-a', {a: cachedPublisherAndVersion});
        storeMock.select.withArgs(selectI18nUpLoaded).and.returnValue(cachedI18n$);

        // The loaded Light Cards have the default publisher with '1' as publisher version
        function randomCardWith1AsPublisherVersion() {
            return getOneRandomCard({publisherVersion: '1'});
        }

        const lightCards = generateRandomArray(2, 7, randomCardWith1AsPublisherVersion);
        localAction$ = new Actions(hot('b', {b: new LoadLightCardsSuccess({lightCards: lightCards})}))
        underTest = new TranslateEffects(storeMock, localAction$, translateServMock, thirdServMock);

        // verification
        expect(underTest).toBeTruthy();

        const expectedEmittedActions = hot('-c', {c: new TranslationUpToDate()});
        expect(underTest.verifyTranslationNeeded).toBeObservable(expectedEmittedActions);

    });
github ngrx / platform / modules / effects / testing / src / testing.ts View on Github external
useFactory: (): Observable => {
      if (typeof factoryOrSource === 'function') {
        return new Actions(defer(factoryOrSource));
      }

      return new Actions(factoryOrSource);
    },
  };
github opfab / operatorfabric-core / ui / main / src / app / store / effects / authentication.effects.spec.ts View on Github external
it('returns CheckAuthenticationStatus on LoadConfigSuccess', () => {
        const localActions$ = new Actions(hot('-a--', {a: new LoadConfigSuccess({config: {}})}));
        effects = new AuthenticationEffects(mockStore, localActions$, null, null, null);
        expect(effects).toBeTruthy();
        effects.checkAuthenticationWhenReady.subscribe((action: AuthenticationActions) => expect(action.type).toEqual(AuthenticationActionTypes.CheckAuthenticationStatus));

    });
github opfab / operatorfabric-core / ui / main / src / app / store / effects / authentication.effects.spec.ts View on Github external
it('returns CheckAuthenticationStatus on LoadConfigSuccess', () => {
        const localActions$ = new Actions(hot('-a--', {a: new LoadConfigSuccess({config: {}})}));
        effects = new AuthenticationEffects(mockStore, localActions$, null, null, null);
        expect(effects).toBeTruthy();
        effects.checkAuthenticationWhenReady.subscribe((action: AuthenticationActions) => expect(action.type).toEqual(AuthenticationActionTypes.CheckAuthenticationStatus));

    });
github tomastrajan / angular-ngrx-material-starter / projects / angular-ngrx-material-starter / src / app / features / examples / crud / books.effects.spec.ts View on Github external
it('should not dispatch any actions', () => {
      const actions = new Actions(EMPTY);
      const effects = new BooksEffects(actions, store, localStorage);
      const metadata = getEffectsMetadata(effects);

      expect(metadata.persistBooks.dispatch).toEqual(false);
    });
github hasadna / open_pension / client / old-client / src / app / effects / quarters.effect.spec.ts View on Github external
it('should dispatch LoadQuartersSuccessAction when LoadQuartersAction dispatched', () => {
    const response = [{
      quarter_id: 1,
      year: '2016',
      month: '1'
    }];

    actions = hot('--a-', { a: new LoadQuartersAction() });
    const expected = cold('--b', {b: new LoadQuartersSuccessAction(response)});
    const service = createServiceStub(response);
    const paiService = createServiceStub(response);
    const effectsAction = new QuartersEffect(new Actions(actions), service, paiService);

    expect(effectsAction.loadQuarters$).toBeObservable(expected);
  });
github hasadna / open_pension / client / old-client / src / app / effects / pai.effect.spec.ts View on Github external
it('should dispatch LoadPaiAfterNewFilterSuccessAction when SelectNewFilterAction dispatched', () => {
    const response = {
      name: 'base',
      children: [{
        name: 'base',
        size: 1160959.768,
      }],
    };

    actions = hot('--a-', { a: new SelectNewFilterAction('currency') });
    const expected = cold('--b', {b: new LoadPaiAfterNewFilterSuccessAction(response)});
    const service = createServiceStub(response);
    const effectsAction = new PaiEffect(new Actions(actions), service);

    expect(effectsAction.loadPaiAfterNewFilter$).toBeObservable(expected);
  });
github bwsw / cloudstack-ui / src / app / root-store / server-data / user-tags / user-tags.effects.spec.ts View on Github external
it('should handle error when deleting a tag in the tag update function and continue execution', () => {
    const actions = new Actions(cold('a', { a: new UpdateLastVMId({ value: 5 }) }));
    const tagService = createTagServiceStub(null, {}, new Error('error'));
    const authService = createAuthServiceStub();
    const store = new StoreStub() as Store;
    const effects = new UserTagsEffects(actions, tagService, authService, store);

    const expected = cold('b', {
      b: new UpdateLastVMIdSuccess({
        key: userTagKeys.lastVMId,
        value: '5',
      }),
    });
    expect(effects.updateLastVmId$).toBeObservable(expected);
  });
github yduartep / angular-ngrx-crud / src / app / games / store / platforms.effects.spec.ts View on Github external
it('should return a GET_PLATFORMS_SUCCESS action, with the platforms, on success', () => {
      service.findAll.and.returnValue(of(MOCK_DATA));
      const source = cold('a', {a: {type: GET_PLATFORMS}});
      const effects = new PlatformEffects(new Actions(source), service);
      const expected = cold('a', {a: new GetAllPlatformsSuccess(MOCK_DATA)});

      expect(effects.getAllPlatforms$).toBeObservable(expected);
    });
github tomastrajan / angular-ngrx-material-starter / projects / angular-ngrx-material-starter / src / app / core / auth / auth.effects.spec.ts View on Github external
it('should not dispatch any action', () => {
      const actions = new Actions(EMPTY);
      const effect = new AuthEffects(actions, localStorageService, router);
      const metadata = getEffectsMetadata(effect);

      expect(metadata.logout.dispatch).toEqual(false);
    });