1
功能我有一個函數:在茉莉花,一個人如何測試使用文件撰寫
var foo = function() {
document.write(bar());
};
我的茉莉花測試:
describe('has a method, foo, that', function() {
it('calls bar', function() {
spyOn(window, 'bar').andReturn('');
foo();
expect(bar).toHaveBeenCalled();
});
});
我的問題是,測試通過,foo
將document.writes寫入頁面,完全覆蓋頁面。有沒有一種很好的方法來測試這個功能?