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 show quote after getQuote (marbles)', () => {
// observable test quote value and complete(), after delay
// #docregion test-quote-marbles
const q$ = cold('---x|', { x: testQuote });
// #enddocregion test-quote-marbles
getQuoteSpy.and.returnValue( q$ );
fixture.detectChanges(); // ngOnInit()
expect(quoteEl.textContent).toBe('...', 'should show placeholder');
// #docregion test-scheduler-flush
getTestScheduler().flush(); // flush the observables
// #enddocregion test-scheduler-flush
fixture.detectChanges(); // update view
expect(quoteEl.textContent).toBe(testQuote, 'should show quote');
expect(errorMessage()).toBeNull('should not show error');
});
// #enddocregion get-quote-test
test(`should handle a delay with a specific retry date time`, () => {
const waitTime = time(`${'-'.repeat(100) }|`);
const emissionTime = new Date(getTestScheduler().now() + waitTime);
const retryErrorWithSpecificDelay = new HttpErrorResponse({
status: 429,
headers: new HttpHeaders({ 'Retry-After': emissionTime.toString() }),
});
getTestScheduler().maxFrames = 1500;
(expect(
errorAfter(3, retryErrorWithSpecificDelay, 1).pipe(
httpRetryer({ scheduler: getTestScheduler() }),
),
) as any).toBeObservable(
// Note the '- 2' account for the time it takes to get to the first error
cold(`ab${ '-'.repeat(100 - 2) }abcd`, {
a: 1,
b: 2,
c: 3,
d: 4,
}),
);
});
it('should show loading when delete stock notification for login user with channel set', () => {
productInterestService.getBackInStockSubscribed.and.returnValue(of(true));
productInterestService.getDeleteBackInStockLoading.and.returnValue(
cold('-a|', { a: true })
);
fixture.detectChanges();
expect(
el.query(By.css('[data-test]="btn-note-stopnotify"')).nativeElement
).toBeTruthy();
const button = el.query(By.css('[data-test="btn-stopnotify"]'))
.nativeElement;
button.click();
getTestScheduler().flush();
fixture.detectChanges();
expect(button.disabled).toEqual(true);
expect(el.query(By.css('.cx-spinner'))).toBeTruthy();
});
it('should be able to disable a channel when update loading', () => {
notificationPreferenceService.getPreferencesLoading.and.returnValue(
of(false)
);
notificationPreferenceService.getUpdatePreferencesResultLoading.and.returnValue(
cold('-a|', { a: true })
);
fixture.detectChanges();
const cheboxies = el.queryAll(By.css('.form-check-input'));
expect(cheboxies.length).toEqual(notificationPreference.length);
const chx = cheboxies[0].nativeElement;
chx.click();
getTestScheduler().flush();
fixture.detectChanges();
expect(notificationPreferenceService.updatePreferences).toHaveBeenCalled();
expect(chx.disabled).toEqual(true);
});
});
it('should call moveToCart()', () => {
spyOn(
component.saveForLaterItemComponent.moveToCart,
'emit'
).and.callThrough();
spyOnProperty(component, 'saveForLaterLoading').and.returnValue(
cold('-b|', { a: true })
);
const moveAction = el.query(By.css('[data-test="move-btn"]')).nativeElement;
moveAction.click();
expect(
component.saveForLaterItemComponent.moveToCart.emit
).toHaveBeenCalledWith(component.item);
getTestScheduler().flush();
fixture.detectChanges();
expect(moveAction.disabled).toEqual(true);
});
});
}
])
);
env.fixture.detectChanges();
expect(env.component.state).toEqual('input');
env.changeSelectValue(env.projectSelect, 'pt01');
expect(env.sourceParatextIdControl.hasError('required')).toBe(true);
expect(env.sourceParatextIdControl.disabled).toBe(false);
env.clickElement(env.inputElement(env.checkingCheckbox));
env.changeSelectValue(env.sourceProjectSelect, 'pt02');
expect(env.component.connectProjectForm.valid).toBe(true);
env.clickElement(env.submitButton);
getTestScheduler().flush();
tick();
expect(env.component.state).toEqual('connecting');
const project = new SFProject({
projectName: 'Target',
paratextId: 'pt01',
inputSystem: {
tag: 'en',
languageName: 'English',
abbreviation: 'en',
isRightToLeft: false
},
checkingConfig: {
enabled: true
},
beforeEach(() => {
responseCache = initMockResponseCacheService(true);
requestService = getMockRequestService();
scheduler = getTestScheduler();
halService = new HALEndpointServiceStub(integrationEndpoint);
findOptions = new IntegrationSearchOptions(uuid, name, metadata, query);
service = initTestService();
});
beforeEach(() => {
scheduler = getTestScheduler();
objectCache = getMockObjectCacheService();
(objectCache.hasBySelfLink as any).and.returnValue(false);
uuidService = getMockUUIDService();
store = new Store(new BehaviorSubject({}), new ActionsSubject(), null);
selectSpy = spyOnProperty(ngrx, 'select');
selectSpy.and.callFake(() => {
return () => {
return () => cold('a', { a: undefined });
};
});
service = new RequestService(
objectCache,
beforeEach(() => {
scheduler = getTestScheduler();
service = initTestService();
});
beforeEach(() => {
requestService = getMockRequestService();
rdbService = getMockRemoteDataBuildService();
scheduler = getTestScheduler();
halService = new HALEndpointServiceStub(resourceEndpointURL);
service = initTestService();
});