我的angularjs控制器中的以下功能的Jasmine单元测试。我正在将TS与angularJS一起使用

时间:2018-10-26 11:26:44

标签: angularjs unit-testing jasmine karma-jasmine angular-services

 public getTxFilterData(): any {
        this.txRejectsService.showLoader = true;
        var momentObj: moment.MomentStatic = moment;
        this.$http({
            url: txRejectsReadApi,
            method: "GET",
            params: {
                startDate: momentObj(this.selectedStartDate).format("MM/DD/YYYY"),
                endDate: momentObj(this.selectedEndDate).format("MM/DD/YYYY"),
                sourceSystem: this.selectedSourceSystem.Name || '',
                eventType: this.selectedEventType.Id || ''
            }
        }).then((response) => {
            var localTxData = this.convertUTCDateTimeToLocal(response.data);
            this.populateGridData(localTxData);
            this.txRowSelected = false;
            this.txRejectsService.showLoader = false;
        }, (error) => {
             this.notificationService.error({
                 message: "Failed to load data. Try again."
             });
            this.txRejectsService.showLoader = false;
            this.$log.error(`error ${error}`);
            this.$log.info(error);
        })
    }

我想专门测试函数内部$ http的.then()块和error()块。我是使用Jasmine进行单元测试的新手,为任何错误道歉。

0 个答案:

没有答案