Category : jasmine

I just start learn using jasmine. I am confused if I need testing function which the value is the function as well, like this is the case on component.ts validationLoadListDownload() { if (this.getGroupId === 0) { this.loadListDownloadRequest(); } else { this.loadListDownloadRequestGroup(); } } if like that, how do we write it on component.spec.ts? I am ..

Read more

Here’s my method inside the typescript file public get(url: any, options?: object): Observable<any> { return this.http.get(url.path, merge(options, { params: { metaData: url } })) .pipe(map((response) => response)); } And following is the unit test case written in Angular8 it(‘Should call Post method’, fakeAsync(() => { service.post(apiUrl, mockRequest.body, options).pipe(take(1)).subcribe((response) => response); // .pipe(take(1)) .subscribe(value => { ..

Read more

So I currently doing some unit tests for an Angular application using Jasmine and Karma. I’m having a problem with a unit test that must open a modal, and remove an item from a tree node. Everything works fine until it reaches the removeItem() function. This removal process uses a confirmationDialogService as follows so the ..

Read more

So i need to make a unit test for the checkBoxesList , my main problem is the formarray i tried everything and have no more ideas how to set a value for this. checkBoxesList() { this.clusterInfos.forEach(() => this.storesFormArray.push(new FormControl(false)) ); } createFormStore() { this.storeDataForm = this.formBuilder.group({ stores: new FormArray([], this.minSelectedCheckboxes(1)), }); this.checkBoxesList(); } get storesFormArray() ..

Read more

I’m using Karma and Jasmine, and I have a function with a $timeout onChange() { console.log(‘onChange’) $timeout(() => { console.log(‘onChange (after timeout)’) }, 100) } now in my test, for some reason, flushing once doesn’t seem to work. onChange() timeout.flush() console.log(‘I should be last’) // logs: // ‘onChange’ // ‘I should be last’ // ‘onChange ..

Read more

I have an Anuglar (version 8) application, that uses ngrx/store and RxJs for angular with this component: export class CarComponent implements OnInit, OnDestroy { // subscriptions private unsubscribe$ = new Subject<void>(); constructor( private activatedRoute: ActivatedRoute, private readonly store: Store<any>, private routingService: RoutingService, private readonly carService: CarService) {} ngOnInit(): void { this.activatedRoute.queryParamMap.pipe( takeUntil(this.unsubscribe$)).subscribe((paramMap: ParamMap) => { ..

Read more