mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-05-28 16:15:43 +08:00
fix(mocks): always call functions injected with inject with this set to the current spec
Currently when a function is injected inside of a test we set the context to undefined which is a bug. Closes #6102
This commit is contained in:
19
test/ngMock/angular-mocksSpec.js
vendored
19
test/ngMock/angular-mocksSpec.js
vendored
@@ -864,6 +864,25 @@ describe('ngMock', function() {
|
||||
});
|
||||
|
||||
|
||||
describe('this', function() {
|
||||
|
||||
it('should set `this` to be the jasmine context', inject(function() {
|
||||
expect(this instanceof jasmine.Spec).toBe(true);
|
||||
}));
|
||||
|
||||
it('should set `this` to be the jasmine context when inlined in a test', function() {
|
||||
var tested = false;
|
||||
|
||||
inject(function() {
|
||||
expect(this instanceof jasmine.Spec).toBe(true);
|
||||
tested = true;
|
||||
});
|
||||
|
||||
expect(tested).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// We don't run the following tests on IE8.
|
||||
// IE8 throws "Object does not support this property or method." error,
|
||||
// when thrown from a function defined on window (which `inject` is).
|
||||
|
||||
Reference in New Issue
Block a user