草庐IT

closeModal

全部标签

javascript - 在 Jest 中调用 React 的 this.props.onClick(this) 时到底应该测试什么?

我一直在为我的所有事件(当然还有其他一切)编写测试,但我不知道如何测试this.props.onClick(this)在子组件上被调用。我的子组件有以下代码:closeModal:function(){this.props.onClick(this);},render:function(){return()}家长是这样听的:onCloseModal:function(){this.replaceState({modalStatus:'hidden'});},render:function(){return()}我知道如何测试parent的点击事件,我也知道如何在测试中调用child的按

html - ngDialog - closeModal 事件 - angularjs

弹出窗口关闭时是否会触发任何事件。模态框在单击事件时打开。模态框有一个关闭按钮,但当用户点击模态框外的任何地方时也会关闭。想要在弹出窗口关闭时执行一些操作。我知道如何编写单击该关闭按钮时的函数,但是如果模态框被其他操作关闭怎么办。app.controller('MainCtrl',function($scope,ngDialog){$scope.clickToOpen=function(){ngDialog.open({template:'popupTmpl.html'});};}); 最佳答案 尝试传递“preCloseCallb