Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should return a LoadConfigsSuccess when the configService serve configuration', () => {
const expectedConfig = {value: {subValue1: 1, subValue2: 2}};
const localActions$ = new Actions(hot('-a--', {a: new LoadConfig()}));
// const localMockConfigService = jasmine.createSpyObj('ConfigService', ['fetchConfiguration']);
configService.fetchConfiguration.and.returnValue(hot('---b', {b: expectedConfig}));
const expectedAction = new LoadConfigSuccess({config: expectedConfig});
const localExpected = hot('---c', {c: expectedAction});
effects = new ConfigEffects(mockStore, localActions$, configService);
expect(effects).toBeTruthy();
expect(effects.loadConfiguration).toBeObservable(localExpected);
});
it('should return a LoadConfigsFailure when the configService doesn\'t serve configuration', () => {
it('should trigger ClearLightCardSelection if navigating from feed/cards/* to somewhere else', () => {
const navigation = {
type: ROUTER_REQUEST,
payload: {
routerState: {
url: "/feed/cards/myCardId"
},
event: new NavigationStart(1,"/archive/")
}
}
const localActions$ = new Actions(hot('-a-', { a: navigation}));
const expectedAction = new ClearLightCardSelection();
const localExpected = hot('-b-', {b: expectedAction});
effects = new CustomRouterEffects(mockStore, localActions$);
expect(effects).toBeTruthy();
expect(effects.navigateAwayFromFeed).toBeObservable(localExpected);
});
// there is no i18n file referenced in the store
const cachedI18n$ = hot('-b', {b:new Map>()});
storeMock.select.withArgs(selectI18nUpLoaded).and.returnValue(cachedI18n$);
expect(underTest).toBeTruthy();
// an UpdateTranslation is expected
const expectedVersions=new Set(lightCards.map(card=>card.publisherVersion));
const expectedThirdAndVersion=generateThirdWithVersion('testPublisher',expectedVersions);
const expectedEmittedActions = hot('-c'
, {
c: new UpdateTranslation({versions: expectedThirdAndVersion})
});
expect(underTest.verifyTranslationNeeded).toBeObservable(expectedEmittedActions);
});
it('should navigate back', () => {
const action = new fromActions.Back();
actions$.stream = hot('-a', { a: action });
spyOn(location, 'back');
effects.navigate$.subscribe(value => {
expect(location.back).toHaveBeenCalled();
});
});
});
it('should emit a success action with content for an action of type readConfiguration', () => {
const payloadInput = { configId: configId };
const action = new ConfiguratorActions.ReadConfiguration(payloadInput);
const completion = new ConfiguratorActions.ReadConfigurationSuccess(
productConfiguration
);
actions$ = hot('-a', { a: action });
const expected = cold('-b', { b: completion });
expect(configEffects.readConfiguration$).toBeObservable(expected);
});
it('should return searchResult from SearchProductsSuccess', () => {
const action = new ProductActions.SearchProducts({
queryText: 'test',
searchConfig: searchConfig,
});
const completion = new ProductActions.SearchProductsSuccess(searchResult);
actions$ = hot('-a', { a: action });
const expected = cold('-b', { b: completion });
expect(effects.searchProducts$).toBeObservable(expected);
});
});
it('should navigate forward', () => {
const action = new RoutingActions.RouteBackAction();
actions$ = hot('-a', { a: action });
spyOn(location, 'forward');
effects.navigate$.subscribe(() => {
expect(location.forward).toHaveBeenCalled();
});
});
});
it('should return suggestions from GetProductSuggestionsSuccess', () => {
const action = new fromActions.GetProductSuggestions({
term: 'test',
searchConfig: new SearchConfig(10)
});
const completion = new fromActions.GetProductSuggestionsSuccess(
suggestions.suggestions
);
actions$.stream = hot('-a', { a: action });
const expected = cold('-b', { b: completion });
expect(effects.getProductSuggestions$).toBeObservable(expected);
});
});
it('should dispatch an error action', () => {
const action = new Actions.Get();
const error = new Actions.GetError();
infotipService.getInfotips.and.returnValue(throwError(new Error()));
actions = hot('--a-', { a: action });
const expected = cold('--b', { b: error });
expect(isObservable(effects.getInfotips$)).toBeTruthy();
});
});
it('should return the resourceSelfLinks for all successful responses', () => {
const source = hot('abcde', testRCEs);
const result = source.pipe(getResourceLinksFromResponse());
const expected = cold('a--d-', {
a: testRCEs.a.response.resourceSelfLinks,
d: testRCEs.d.response.resourceSelfLinks
});
expect(result).toBeObservable(expected);
});
});