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 not add a question if cancelled', fakeAsync(() => {
const env = new TestEnvironment();
when(env.mockedQuestionDialogRef.afterClosed()).thenReturn(of('close'));
env.fixture.detectChanges();
flush();
verify(env.mockedTextService.getQuestionData(anything())).twice();
resetCalls(env.mockedTextService);
env.clickElement(env.addQuestionButton);
verify(env.mockedMdcDialog.open(anything(), anything())).once();
verify(env.mockedTextService.getQuestionData(anything())).never();
expect().nothing();
}));
it('update confidence threshold', fakeAsync(() => {
const env = new TestEnvironment();
env.setTranslateConfig({
selectedTextRef: 'text01',
selectedChapter: 1,
selectedSegment: 'verse_1_2',
confidenceThreshold: 0.5
});
env.waitForSuggestion();
expect(env.component.confidenceThreshold).toBe(50);
expect(env.component.showSuggestion).toBe(true);
tick(10000);
resetCalls(env.mockedSFProjectUserService);
env.clickSuggestionsMenuButton();
env.updateConfidenceThresholdSlider(60);
expect(env.component.confidenceThreshold).toBe(60);
verify(env.mockedSFProjectUserService.update(anything())).once();
expect(env.component.showSuggestion).toBe(false);
resetCalls(env.mockedSFProjectUserService);
env.updateConfidenceThresholdSlider(40);
expect(env.component.confidenceThreshold).toBe(40);
verify(env.mockedSFProjectUserService.update(anything())).once();
expect(env.component.showSuggestion).toBe(true);
env.dispose();
}));
it('should redirect if triggered', fakeAsync(() => {
resetCalls(router);
const action = new fromActions.LoadProductsForCategoryFail({
categoryId: 'ID',
error: { status: 404 } as HttpError,
});
actions$ = of(action);
effects.redirectIfErrorInCategoryProducts$.subscribe(noop, fail, noop);
tick(500);
expect(location.path()).toEqual('/error');
}));
});
it('local and remote selected segment are different', fakeAsync(() => {
const env = new TestEnvironment();
env.setTranslateConfig({ selectedTextRef: 'text01', selectedChapter: 1, selectedSegment: 'verse_1_1' });
env.waitForSuggestion();
expect(env.component.chapter).toBe(1);
expect(env.component.target.segmentRef).toBe('verse_1_1');
verify(env.mockedRemoteTranslationEngine.translateInteractively(1, anything())).once();
resetCalls(env.mockedRemoteTranslationEngine);
env.setTranslateConfig({ selectedTextRef: 'text01', selectedChapter: 1, selectedSegment: 'verse_1_2' });
env.waitForSuggestion();
expect(env.component.target.segmentRef).toBe('verse_1_2');
verify(env.mockedRemoteTranslationEngine.translateInteractively(1, anything())).once();
env.dispose();
}));
{ type: 'Link', uri: 'customers/CID/users/UID/quoterequests/QRID4' },
],
}).pipe(delay(100))
);
when(apiServiceMock.post('customers/CID/users/UID/quoterequests/QRID2/items', anything())).thenReturn(
of(undefined)
);
when(apiServiceMock.post('customers/CID/users/UID/quoterequests/QRID3/items', anything())).thenReturn(
of(undefined)
);
when(apiServiceMock.post('customers/CID/users/UID/quoterequests/QRID4/items', anything())).thenReturn(
of(undefined)
);
store$.reset();
resetCalls(apiServiceMock);
setTimeout(() => store$.dispatch(new AddProductToQuoteRequest({ sku: 'SKU', quantity: 1 })), 400);
setTimeout(() => store$.dispatch(new AddProductToQuoteRequest({ sku: 'SKU', quantity: 1 })), 450);
setTimeout(() => store$.dispatch(new AddProductToQuoteRequest({ sku: 'SKU', quantity: 1 })), 480);
});
tick(SEND_METRICS_INTERVAL);
verify(
env.mockedSFProjectService.addTranslateMetrics(
'project01',
deepEqual({
id: env.session.metrics.id,
type: 'navigate',
sessionId: env.session.id,
textRef: 'text01',
chapter: 1,
keyNavigationCount: 2
})
)
).once();
resetCalls(env.mockedSFProjectService);
env.mouseClick();
expect(env.session.metrics.type).toBe('navigate');
expect(env.session.metrics.mouseClickCount).toBe(1);
verify(env.mockedSFProjectService.addTranslateMetrics('project01', anything())).never();
tick(SEND_METRICS_INTERVAL);
verify(
env.mockedSFProjectService.addTranslateMetrics(
'project01',
deepEqual({
id: env.session.metrics.id,
type: 'navigate',
sessionId: env.session.id,
textRef: 'text01',
chapter: 1,
keyNavigationCount: 2,