Unit test case for a method having subscribe

Viewed 28

I want to write unit test cases for the the below function:

submit() {
this.displayLoader = true;
let reqobj = {
settlementDate: this.date,
carrierCode: this.selectedBatch,
notes: this.formData.get('comments')?.value
}
this.apiService.createBatch(reqObj).subscribe(res => {
this.createBatchResponse = res;
this.batchNum = this.createBatchResponse.BatchNum;
this.showCreateSuccessMessage = true;
this.enableDeleteButton = false;
this.displayLoader = false;
this.submitDisable = true;
},
error => {
this.showCreateSuccessMessage = true;
this.receivedErrorMessages = new Array<IErrorMessage>();
this.receivedErrorMessages = error;
this.showErrorComponent = true;
this.enableDeleteButton = false;
this.displayLoader = false;
this.submitDisable = false;
});
}

P.S - I'm new in writing test cases. And have no idea how to move forward with this.

Thanks in advance. Any help is appreciated

0 Answers
Related