2015-10-20 65 views
1

我正在使用ngMaterial的角度。我正在使用它随附的md-toast。问题是吐司使用超时而不是间隔,量角器不喜欢它们。量角器嘲笑类

我只是想从我的测试中删除md-toast调用。我所有的md-toast调用都在这个类中:

# Coffeescript 
class MyAppController extends MyAppBase 
    showToast: (msg, type) -> 
     @rootScope.customToastMessage = 
      toast_type: type 
      messageString: msg 

     @rootScope.appctrl.openCustomToastMessage() 

可以更改量角器测试中的showToast方法吗?

+1

看到的是https:// github.com/angular/material/issues/2704了解更多信息问题 –

回答

1

你应该看看量角器的addMockModule()

http://angular.github.io/protractor/#/api?view=Protractor.prototype.addMockModule

(一些更多的信息:http://eitanp461.blogspot.be/2014/01/advanced-protractor-features.html

实例模拟:

var MdToastMock = function() { 

    this.show = function (toast) { 
    this.position = toast._position; 
    this.content = toast._content; 
    }; 

    this.simple = function() { 
    var self = this; 
    self.content = function (content) { 
     self._content = content; 
     return self; 
    }; 
    self._position = ''; 
    self.position = function (position) { 
     self._position = position; 
     return self; 
    }; 
    return this; 
    }; 

    spyOn(this, 'show').and.callThrough(); 
}; 

return MdToastMock;