我正在使用茉莉花進行測試。如何檢查給定的jQuery選擇器上是否調用了方法?
基本上我想確保一個特定的方法正在執行給定的jQuery選擇器。
例如
$('.hidden-tag').show()
目前,我有以下幾點:
describe("Test", function() {
beforeEach(function() {
spyOn(window, '$').andCallThrough();
loadFixtures('my_fixture.html');
});
it("should call show method on the jQuery selector '.hidden-tag'", function() {
expect($).toHaveBeenCalledWith('.hidden-tag');
});
});
第一部分作品。我如何得到它來檢查'show'方法是否被調用?
據我所知沒有直接的方法來做到這一點...可能是一個小黑客可以幫你 –
像http://jsfiddle.net/arunpjohny/GhMRs/1/ –