Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Doesn't seem to trigger jQuery Ajax Hooks #28

Closed
hhff opened this issue Nov 27, 2015 · 6 comments
Closed

Doesn't seem to trigger jQuery Ajax Hooks #28

hhff opened this issue Nov 27, 2015 · 6 comments

Comments

@hhff
Copy link

hhff commented Nov 27, 2015

Hi Taras!

I'm using ember-ajax from inside a component (to post an email to a mailing list).

I'm trying to write integration tests for the component, using wait().

(The code for wait is here.)

I do something like

this.$('button').click();

return wait().then(() => {
  // assertions
  asset.ok(...something);
});

However when I call debugger inside the wait function (in the link above) the value of requests is an empty array. I'd assume that means jQuery(document).on('ajaxSend', incrementAjaxPendingRequests); and jQuery(document).on('ajaxComplete', decrementAjaxPendingRequests); aren't being called.

Do you have any thoughts / experience here?

@taras
Copy link
Contributor

taras commented Dec 2, 2015

Can you please put a breakpoint on https://github.com/switchfly/ember-test-helpers/blob/b04cc9cff517d3df9f4fde96b8c1839ec10cc91d/lib/ember-test-helpers/test-module.js#L190 and see if it's being triggered?

Ember Ajax isn't doing anything special to jQuery Ajax that would change default behaviour. If that is setup, it should work.

@hhff
Copy link
Author

hhff commented Dec 2, 2015

Just debug'd that breakpoint - the hooks are being successfully setup - but when I debug here the hook is never fired.

This is from a WIP addon - I'll push it up now so I can show an example

@taras
Copy link
Contributor

taras commented Dec 2, 2015

Is the setup function called before your test starts or when wait() is called?

@alexlafroscia
Copy link
Collaborator

This should have been addressed with #40, right?

@taras
Copy link
Contributor

taras commented Jan 21, 2016

Yes, @hhff can reopen this if it's still a problem ;)

@taras taras closed this as completed Jan 21, 2016
@hhff
Copy link
Author

hhff commented Jan 22, 2016

Oh sweet - will test on the weekend ❤️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants