Hello folks!

I've checked the angular-mocks source code and the new Jasmine 2.0 async 
tests. I was thinking about injecting this "done" function as a local 
variable in the angular mocks for convenience.

Here's a question on SO that talks about the new syntax. This answer is how 
I decided to write my tests: http://stackoverflow.com/a/27673009

Now, looking at the angular-mocks code, I saw that each call to inject(fn) 
will make a new injector and invoke the "fn" as in $injector.invoke(fn, 
this);

So, before making a pull request, I'd like to see some opinions. 

This is what the tests look like

it('should do something', function(done){
    // here's a call to $injector.invoke
    inject(function(MyService) {
        // here's the actual test
        MyService.doSomeAsync().then(function(result) {
            expect(result).not.toBeUndefined();
            done();
        });
    });
});


This is how it would be with a little change in angular-mocks code:

it('should do something', function(done, MyService){
    // now with the async callback as a local variable
    MyService.doSomeAsync().then(function(result) {
        expect(result).not.toBeUndefined();
        done();
    });
});


Worth the effort?

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to