尽管使用导出使函数成为全局函数,Jasmine也不会实例化构造函数的对象

时间:2016-07-12 04:31:23

标签: function jasmine prototype

我有一个本地的一个js文件的函数,但导出用于使其全局。当我试图在规范中实例化它时,jasmine抛出一个错误,说明函数没有定义。

RoomReservation功能:

RoomReservation = (function() {
RoomReservation.prototype.searchRatePlans = function(search, callback, filter) {
....
        };

return RoomReservation;
  })();
exports.RoomReservation = RoomReservation;

Jasmine Spec:

it('To test RoomReservation function',function(){
                    var filter='groupCode';
                    var search='g';
                    spyOn(RoomReservation.prototype, 'searchRatePlans'); 
                    var k = new RoomReservation();
                    expect(k.searchRatePlans).toHaveBeenCalled();
                });

0 个答案:

没有答案