如何使用茉莉花测试箭头功能(角度)

时间:2020-05-13 01:20:46

标签: angular unit-testing jasmine karma-runner arrow-functions

如何测试此功能?

    public openOverlayScope(data: any){
      return () => {
        this._billerService.dataBiller = data;
        this._openOverlayToken();
        this._dialogRef.close();
    }
  }

我需要创建此函数以在以下函数中将其作为参数发送,并且使代码的测试更加容易

public openOverlayActiveService(data: Biller) {
        this._dialogRef = this._dialog.open(
            {
                closeLabel: 'Cerrar',
                title: 'Alta de servicio',
                enableHr: false,
                disabledButton: true,
                buttons: [
                    {
                        label: 'Confirmar',
                        class: 'strech',
                        action: scope => { //  replace with openOverlayScope()
                        this._billerService.dataBiller = data;
                        this._openOverlayToken();
                        this._dialogRef.close();
                        }
                    }
                ]
            },
            new CustomDialog(ActivateServiceComponent, { data })
        );
    }

0 个答案:

没有答案