@@ -167,6 +167,7 @@ describe('$mdCompiler service', function() {
167
167
[
168
168
{ respectPreAssignBindingsEnabled : true } ,
169
169
{ respectPreAssignBindingsEnabled : false } ,
170
+ // TODO change `equivalentTo` to `true` in Material 1.2.
170
171
{ respectPreAssignBindingsEnabled : '"default"' , equivalentTo : false }
171
172
] . forEach ( function ( options ) {
172
173
var realRespectPreAssignBindingsEnabled = options . respectPreAssignBindingsEnabled ;
@@ -175,13 +176,15 @@ describe('$mdCompiler service', function() {
175
176
realRespectPreAssignBindingsEnabled ;
176
177
177
178
describe ( 'with respectPreAssignBindingsEnabled set to ' + realRespectPreAssignBindingsEnabled , function ( ) {
179
+ var $mdCompilerProvider ;
178
180
var preAssignBindingsEnabledInAngularJS = angular . version . minor < 6 ;
179
181
180
182
beforeEach ( function ( ) {
181
- module ( function ( $mdCompilerProvider ) {
182
- console . log ( angular . version , preAssignBindingsEnabledInAngularJS ) ;
183
+ module ( function ( _$mdCompilerProvider_ ) {
184
+ $mdCompilerProvider = _$mdCompilerProvider_ ;
185
+
183
186
// Don't set the value so that the default state can be tested.
184
- if ( realRespectPreAssignBindingsEnabled === true || realRespectPreAssignBindingsEnabled === false ) {
187
+ if ( typeof realRespectPreAssignBindingsEnabled === 'boolean' ) {
185
188
$mdCompilerProvider . respectPreAssignBindingsEnabled ( realRespectPreAssignBindingsEnabled ) ;
186
189
}
187
190
} ) ;
@@ -202,13 +205,33 @@ describe('$mdCompiler service', function() {
202
205
return compileData ;
203
206
}
204
207
208
+ it ( 'should call $onInit even if bindToController is set to false' , function ( ) {
209
+ var isInstantiated = false ;
210
+
211
+ function TestController ( $scope , name ) {
212
+ isInstantiated = true ;
213
+ expect ( $scope . $apply ) . toBeTruthy ( ) ;
214
+ expect ( name ) . toBe ( 'Bob' ) ;
215
+ }
216
+
217
+ TestController . prototype . $onInit = jasmine . createSpy ( '$onInit' ) ;
218
+
219
+ compileAndLink ( {
220
+ template : 'hello' ,
221
+ controller : TestController ,
222
+ bindToController : false ,
223
+ locals : { name : 'Bob' }
224
+ } ) ;
225
+
226
+ expect ( TestController . prototype . $onInit ) . toHaveBeenCalledTimes ( 1 ) ;
227
+ expect ( isInstantiated ) . toBe ( true ) ;
228
+ } ) ;
229
+
205
230
// Bindings are not preassigned only if we respect the AngularJS config and they're
206
231
// disabled there. This logic will change in Material 1.2.0.
207
232
if ( respectPreAssignBindingsEnabled && ! preAssignBindingsEnabledInAngularJS ) {
208
233
it ( '$mdCompileProvider.preAssignBindingsEnabled should report bindings are not pre-assigned' , function ( ) {
209
- module ( function ( $mdCompilerProvider ) {
210
- expect ( $mdCompilerProvider . preAssignBindingsEnabled ( ) ) . toBe ( false ) ;
211
- } ) ;
234
+ expect ( $mdCompilerProvider . preAssignBindingsEnabled ( ) ) . toBe ( false ) ;
212
235
} ) ;
213
236
214
237
it ( 'disabled should assign bindings after constructor' , function ( ) {
@@ -239,9 +262,7 @@ describe('$mdCompiler service', function() {
239
262
} ) ;
240
263
} else {
241
264
it ( '$mdCompileProvider.preAssignBindingsEnabled should report bindings are pre-assigned' , function ( ) {
242
- module ( function ( $mdCompilerProvider ) {
243
- expect ( $mdCompilerProvider . preAssignBindingsEnabled ( ) ) . toBe ( false ) ;
244
- } ) ;
265
+ expect ( $mdCompilerProvider . preAssignBindingsEnabled ( ) ) . toBe ( true ) ;
245
266
} ) ;
246
267
247
268
it ( 'enabled should assign bindings at instantiation' , function ( ) {
0 commit comments