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 submit when email or username is specified', fakeAsync(() => {
const env = new TestEnvironment();
when(env.mockedIdentityService.forgotPassword(anything())).thenResolve(true);
env.fixture.detectChanges();
env.setInputValue(env.userInput, 'user');
env.clickSubmitButton();
verify(env.mockedIdentityService.forgotPassword(deepEqual('user'))).once();
verify(env.mockedNoticeService.show(anyString())).once();
expect().nothing();
flush();
}));
it('navigate to last text', fakeAsync(() => {
const env = new TestEnvironment();
env.setProjectData({ selectedTask: 'translate' });
env.fixture.detectChanges();
flush();
verify(env.mockedRouter.navigate(deepEqual(['./', 'translate', 'text02']), anything())).once();
expect().nothing();
}));
private addTextData(id: TextDataId): void {
when(this.mockedTextService.getTextData(deepEqual(id))).thenResolve(this.createTextData(id));
}
}
},
checkingConfig: {
enabled: true
},
translateConfig: {
enabled: true,
sourceParatextId: 'pt02',
sourceInputSystem: {
languageName: 'Spanish',
tag: 'es',
isRightToLeft: false,
abbreviation: 'es'
}
}
});
verify(env.mockedSFProjectService.onlineCreate(deepEqual(project))).once();
verify(env.mockedSFProjectUserService.onlineCreate('project01', 'user01')).once();
verify(env.mockedRouter.navigate(deepEqual(['/projects', 'project01']))).once();
}));
effects.updateSubmitQuoteRequest$.subscribe(action => {
verify(quoteRequestServiceMock.updateQuoteRequest('QRID', deepEqual({ displayName: 'edited' }))).once();
expect(action).toMatchInlineSnapshot(`
[Quote API] Update Quote Request Fail:
error: {"message":"something went wrong"}
`);
done();
});
});
setNoProjectData(): void {
when(
this.mockedSFProjectService.get(
'project01',
deepEqual([[nameof('users')], [nameof('texts')]])
)
).thenReturn(of(new MapQueryResults(null)));
}
private addTextData(id: TextDataId): void {
when(this.mockedTextService.getTextData(deepEqual(id))).thenResolve(this.createTextData(id));
}
setProjectData(args: { isTranslateEnabled?: boolean; hasTexts?: boolean; selectedTask?: string }): void {
when(
this.mockedSFProjectService.get(
'project01',
deepEqual([[nameof('users')], [nameof('texts')]])
)
).thenReturn(
of(
new MapQueryResults(
new SFProject({
id: 'project01',
translateConfig: { enabled: args.isTranslateEnabled == null || args.isTranslateEnabled },
checkingConfig: { enabled: true },
users: [new SFProjectUserRef('projectuser01')],
texts: args.hasTexts == null || args.hasTexts ? [new TextRef('text01'), new TextRef('text02')] : undefined
}),
undefined,
[
new SFProjectUser({
id: 'projectuser01',
user: new UserRef('user01'),
{ id: 'text02', bookId: 'LUK', name: 'Luke', chapters: [{ number: 1 }] } as Text
])
);
const text1_1id = new TextJsonDataId('text01', 1);
when(this.mockedTextService.getQuestionData(deepEqual(text1_1id))).thenResolve(
this.createQuestionData(text1_1id, [
{ id: 'q1Id', ownerRef: undefined, projectRef: undefined, text: 'Book 1, Q1 text' },
{ id: 'q2Id', ownerRef: undefined, projectRef: undefined, text: 'Book 1, Q2 text' }
])
);
const text1_3id = new TextJsonDataId('text01', 3);
when(this.mockedTextService.getQuestionData(deepEqual(text1_3id))).thenResolve(
this.createQuestionData(text1_3id, [])
);
const text2_1id = new TextJsonDataId('text02', 1);
when(this.mockedTextService.getQuestionData(deepEqual(text2_1id))).thenResolve(
this.createQuestionData(text2_1id, [
{ id: 'q3Id', ownerRef: undefined, projectRef: undefined, text: 'Book 2, Q3 text' }
])
);
TestBed.configureTestingModule({
imports: [DialogTestModule],
declarations: [CheckingOverviewComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
{ provide: ActivatedRoute, useFactory: () => instance(this.mockedActivatedRoute) },
{ provide: SFAdminAuthGuard, useFactory: () => instance(this.mockedSFAdminAuthGuard) },
{ provide: MdcDialog, useFactory: () => instance(this.mockedMdcDialog) },
{ provide: NoticeService, useFactory: () => instance(this.mockedNoticeService) },
{ provide: SFProjectService, useFactory: () => instance(this.mockedProjectService) },
{ provide: TextService, useFactory: () => instance(this.mockedTextService) },