diff options
| author | Wes Alvaro | 2014-02-03 16:53:52 -0800 |
|---|---|---|
| committer | Igor Minar | 2014-02-03 22:25:30 -0800 |
| commit | 3bf43903397c703aa2e9ba1e1a48dbc9e8286ee2 (patch) | |
| tree | ee0bf903169930a4a17ed4e1c633cf7ae21eb251 /test | |
| parent | e7ac7aa43b88932a08140c2dabb8000e285f06d7 (diff) | |
| download | angular.js-3bf43903397c703aa2e9ba1e1a48dbc9e8286ee2.tar.bz2 | |
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
Diffstat (limited to 'test')
| -rw-r--r-- | test/ngMock/angular-mocksSpec.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js index fb602adc..e5f67a7e 100644 --- a/test/ngMock/angular-mocksSpec.js +++ b/test/ngMock/angular-mocksSpec.js @@ -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). |
