admin管理员组文章数量:1318564
I'm using the jQuery-Jasmine extension to spy on events but i can't get the correct syntax.
// Get a button
var $button = $( '#ai1ec_subscribe_users' );
// Call the function
utility_functions.block_all_submit_and_ajax( $button.get(0) );
// check that all submit are disabled
var first_multi = $( '.ai1ec-facebook-refresh-multiselect:first' );
spyOnEvent( '.ai1ec-facebook-refresh-multiselect:first', 'click' );
first_multi.click();
expect( 'click' ).toHaveBeenTriggeredOn( '.ai1ec-facebook-refresh-multiselect:first' );
This gives me back
Expected event click to have been triggered on .ai1ec-facebook-refresh-multiselect:first
but i clicked it on the row before the check so i must be doing something wrong.
I'm using the jQuery-Jasmine extension to spy on events but i can't get the correct syntax.
// Get a button
var $button = $( '#ai1ec_subscribe_users' );
// Call the function
utility_functions.block_all_submit_and_ajax( $button.get(0) );
// check that all submit are disabled
var first_multi = $( '.ai1ec-facebook-refresh-multiselect:first' );
spyOnEvent( '.ai1ec-facebook-refresh-multiselect:first', 'click' );
first_multi.click();
expect( 'click' ).toHaveBeenTriggeredOn( '.ai1ec-facebook-refresh-multiselect:first' );
This gives me back
Expected event click to have been triggered on .ai1ec-facebook-refresh-multiselect:first
but i clicked it on the row before the check so i must be doing something wrong.
Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Jun 9, 2012 at 14:54 Nicola PeluchettiNicola Peluchetti 76.9k32 gold badges149 silver badges195 bronze badges1 Answer
Reset to default 6The problem was that I wasn't triggering the event in the right way.
This worked:
it( "Prevent all ajax functionality", function() {
// Get a button
var $button = $( '#ai1ec_subscribe_users' );
// Call the function
utility_functions.block_all_submit_and_ajax( $button.get(0) );
// check that all submit are disabled
spyOnEvent( $( '.ai1ec-facebook-refresh-multiselect:first' ), 'click' );
$( '.ai1ec-facebook-refresh-multiselect:first' )[0].click();
expect( 'click' ).toHaveBeenTriggeredOn( $( '.ai1ec-facebook-refresh-multiselect:first' ) );
} );
本文标签: javascriptHow to use SpyOnEvent to spy on events with jqueryjasmineStack Overflow
版权声明:本文标题:javascript - How to use SpyOnEvent to spy on events with jquery-jasmine - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742049601a2417996.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论