Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'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);
});
useFactory: (): Observable => {
if (typeof factoryOrSource === 'function') {
return new Actions(defer(factoryOrSource));
}
return new Actions(factoryOrSource);
},
};
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));
});
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));
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});