Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example doesn't show how to handle async blocks #2

Open
fatuhoku opened this issue Apr 12, 2015 · 1 comment
Open

Example doesn't show how to handle async blocks #2

fatuhoku opened this issue Apr 12, 2015 · 1 comment

Comments

@fatuhoku
Copy link

The example given in the README:

    expect(getUser()).toBeUndefined();

    loadUser(); //function that invokes Query.find

    expect(getUser()).toBeDefined();
    expect(stub.callCount).toEqual(1); //do assertions on stub object if necessary

Sorry, I'm relatively new to Javascript Async unit testing. It's always useful to have these things spelled out for newbies ;).

@dziamid
Copy link
Owner

dziamid commented Apr 13, 2015

Absolutely, I will update the examples. Meanwhile, if need to test a function that returns a promise, then you should chain to that promise:

    loadUser().then(function () { //load user returns a promise
      expect(getUser()).toBeDefined();
      expect(stub.callCount).toEqual(1); //do assertions on stub object if necessary
    });

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

No branches or pull requests

2 participants