@@ -54,7 +54,8 @@ beforeEach(function () {
54
54
O : { resolve : { _O : function ( _O2 ) { return _O2 + "O" ; } , _O2 : function ( _O ) { return _O + "O2" ; } } } ,
55
55
P : { resolve : { $state : function ( $state ) { return $state } } ,
56
56
Q : { resolve : { _Q : function ( $state ) { counts . _Q ++ ; vals . _Q = $state ; return "foo" ; } } }
57
- }
57
+ } ,
58
+ PAnnotated : { resolve : { $state : [ '$state' , function ( $state ) { return $state } ] } }
58
59
} ;
59
60
60
61
var stateProps = [ "resolve" , "resolvePolicy" ] ;
@@ -95,6 +96,48 @@ describe('Resolvables system:', function () {
95
96
asyncCount = 0 ;
96
97
} ) ) ;
97
98
99
+ describe ( 'strictDi support' , function ( ) {
100
+ let originalStrictDi : boolean ;
101
+ let supportsStrictDi = false ;
102
+
103
+ beforeEach ( inject ( function ( $injector ) {
104
+ // not all angular versions support strictDi mode.
105
+ // here, we detect the feature
106
+ try {
107
+ $injector . annotate ( ( ) => { } , true ) ;
108
+ } catch ( e ) {
109
+ supportsStrictDi = true ;
110
+ }
111
+
112
+ if ( supportsStrictDi ) {
113
+ originalStrictDi = $injector . strictDi ;
114
+ $injector . strictDi = true ;
115
+ }
116
+ } ) ) ;
117
+
118
+ afterEach ( inject ( function ( $injector ) {
119
+ if ( supportsStrictDi ) {
120
+ $injector . strictDi = originalStrictDi ;
121
+ }
122
+ } ) ) ;
123
+
124
+ it ( 'should throw when creating a resolvable with an unannotated fn and strictDi mode on' , inject ( function ( $injector ) {
125
+ if ( supportsStrictDi ) {
126
+ expect ( ( ) => {
127
+ makePath ( [ "P" ] ) ;
128
+ } ) . toThrowError ( / s t r i c t d i / ) ;
129
+ }
130
+ } ) ;
131
+
132
+ it ( 'should not throw when creating a resolvable with an annotated fn and strictDi mode on' , inject ( function ( $injector ) {
133
+ if ( supportsStrictDi ) {
134
+ expect ( ( ) => {
135
+ makePath ( [ "PAnnotated" ] ) ;
136
+ } ) . not . toThrowError ( / s t r i c t d i / ) ;
137
+ }
138
+ } ) ;
139
+ } ) ;
140
+
98
141
describe ( 'ResolveContext.resolvePathElement()' , function ( ) {
99
142
it ( 'should resolve all resolves in a PathElement' , inject ( function ( $q ) {
100
143
let path = makePath ( [ "A" ] ) ;
0 commit comments