1
我有一個簡單的反應組件,其中有一個onClick事件可以重定向到另一個頁面 - Google搜索引擎(用於測試目的)。使用Mocha,Karma測試window.location.href中的window.location.href
這裏的的jsfiddle鏈接的陣營組成部分 - http://jsfiddle.net/t9dva2f7/
describe('Events', function() {
it('should have click event state', function (done) {
var events = Events();
ReactTestUtils.renderIntoDocument(events);
ReactTestUtils.Simulate.click(events.refs.button.getDOMNode());
//Test to see if the page redirects to correct url?
done();
});
});
如何測試瀏覽器被重定向到正確的網址是什麼?我應該嘲笑window.location.href?或者還有別的嗎?