This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -2125,7 +2125,7 @@ if(window.jasmine || window.mocha) {
2125
2125
window . inject = angular . mock . inject = function ( ) {
2126
2126
var blockFns = Array . prototype . slice . call ( arguments , 0 ) ;
2127
2127
var errorForStack = new Error ( 'Declaration Location' ) ;
2128
- return isSpecRunning ( ) ? workFn ( ) : workFn ;
2128
+ return isSpecRunning ( ) ? workFn . call ( currentSpec ) : workFn ;
2129
2129
/////////////////////
2130
2130
function workFn ( ) {
2131
2131
var modules = currentSpec . $modules || [ ] ;
Original file line number Diff line number Diff line change @@ -864,6 +864,25 @@ describe('ngMock', function() {
864
864
} ) ;
865
865
866
866
867
+ describe ( 'this' , function ( ) {
868
+
869
+ it ( 'should set `this` to be the jasmine context' , inject ( function ( ) {
870
+ expect ( this instanceof jasmine . Spec ) . toBe ( true ) ;
871
+ } ) ) ;
872
+
873
+ it ( 'should set `this` to be the jasmine context when inlined in a test' , function ( ) {
874
+ var tested = false ;
875
+
876
+ inject ( function ( ) {
877
+ expect ( this instanceof jasmine . Spec ) . toBe ( true ) ;
878
+ tested = true ;
879
+ } ) ;
880
+
881
+ expect ( tested ) . toBe ( true ) ;
882
+ } ) ;
883
+ } ) ;
884
+
885
+
867
886
// We don't run the following tests on IE8.
868
887
// IE8 throws "Object does not support this property or method." error,
869
888
// when thrown from a function defined on window (which `inject` is).
You can’t perform that action at this time.
0 commit comments