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

Mocking callbacks #39

Open
jackmatt2 opened this issue Aug 15, 2015 · 0 comments
Open

Mocking callbacks #39

jackmatt2 opened this issue Aug 15, 2015 · 0 comments

Comments

@jackmatt2
Copy link

I am trying to use this library to test a deeply nested async call using callbacks.

var self = this;
this.store.find('employee').then(function(employee) { //promise #1
   employee.get('address').then(function(address) { //promise #2
      self.set('suburb', address.get('suburb')); //I don't care how I get here but I want to test this!
   });
});

In this case, this.store is a mock().

var mockStore = mock(DS.Store);
when(mockStore).find('employee').thenReturn(...)

What I want is to control what address is in the final callback and make sure self.suburb === address.suburb. I can't get this working because once I start mocking I have to mock our each successive return value and therefore never actually hit the code that sets the suburb.

Is this possible using jsmockito? Am I doing something wrong?

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

1 participant