3
我已經在的jsfiddle創建a simple example來測試我在項目中遇到的問題執行:測試該功能在ES6構造用茉莉花
describe('testing es6 and jasmine', function() {
describe('let',() => {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let
it('is es6 works', function() {
class Test {
constructor() {
var x = this.sum(1, 1);
}
sum(a, b) {
return a + b;
}
}
var test = new Test();
spyOn(test, 'sum').and.callThrough();
expect(test.sum).toBeDefined();
expect(test.constructor).toBeDefined();
expect(test.sum).toHaveBeenCalled();
});
});
});
問題是,我在構造函數中執行的方法,我想檢查它是否被執行。爲什麼在我的例子中,茉莉花告訴它不是?