@@ -4244,6 +4244,22 @@ describe('$compile', function() {
4244
4244
if ( ! / c h r o m e / i. test ( navigator . userAgent ) ) return ;
4245
4245
/*jshint -W061 */
4246
4246
var controllerCalled = false ;
4247
+ var Controller = eval (
4248
+ "class Foo {\n" +
4249
+ " constructor($scope) {}\n" +
4250
+ " $onInit() { this.check(); }\n" +
4251
+ " check() {\n" +
4252
+ " expect(this.data).toEqualData({\n" +
4253
+ " 'foo': 'bar',\n" +
4254
+ " 'baz': 'biz'\n" +
4255
+ " });\n" +
4256
+ " expect(this.str).toBe('Hello, world!');\n" +
4257
+ " expect(this.fn()).toBe('called!');\n" +
4258
+ " controllerCalled = true;\n" +
4259
+ " }\n" +
4260
+ "}" ) ;
4261
+ spyOn ( Controller . prototype , '$onInit' ) ;
4262
+
4247
4263
module ( function ( $compileProvider ) {
4248
4264
$compileProvider . directive ( 'fooDir' , valueFn ( {
4249
4265
template : '<p>isolate</p>' ,
@@ -4252,20 +4268,7 @@ describe('$compile', function() {
4252
4268
'str' : '@dirStr' ,
4253
4269
'fn' : '&dirFn'
4254
4270
} ,
4255
- controller : eval (
4256
- "class Foo {" +
4257
- " constructor($scope) {}" +
4258
- " check() {" +
4259
- " expect(this.data).toEqualData({" +
4260
- " 'foo': 'bar'," +
4261
- " 'baz': 'biz'" +
4262
- " });" +
4263
- " expect(this.str).toBe('Hello, world!');" +
4264
- " expect(this.fn()).toBe('called!');" +
4265
- " controllerCalled = true;" +
4266
- " }" +
4267
- "}"
4268
- ) ,
4271
+ controller : Controller ,
4269
4272
controllerAs : 'test' ,
4270
4273
bindToController : true
4271
4274
} ) ) ;
@@ -4280,13 +4283,15 @@ describe('$compile', function() {
4280
4283
element = $compile ( '<div foo-dir dir-data="remoteData" ' +
4281
4284
'dir-str="Hello, {{whom}}!" ' +
4282
4285
'dir-fn="fn()"></div>' ) ( $rootScope ) ;
4286
+ expect ( Controller . prototype . $onInit ) . toHaveBeenCalled ( ) ;
4283
4287
element . data ( '$fooDirController' ) . check ( ) ;
4284
4288
expect ( controllerCalled ) . toBe ( true ) ;
4285
4289
} ) ;
4286
4290
/*jshint +W061 */
4287
4291
} ) ;
4288
4292
4289
4293
4294
+
4290
4295
it ( 'should update @-bindings on controller when bindToController and attribute change observed' , function ( ) {
4291
4296
module ( function ( $compileProvider ) {
4292
4297
$compileProvider . directive ( 'atBinding' , valueFn ( {
0 commit comments