@@ -259,36 +259,33 @@ describe('uiCodemirror', function() {
259
259
260
260
it ( 'when the IDE changes should update the model' , function ( ) {
261
261
var element = $compile ( '<div ui-codemirror ng-model="foo"></div>' ) ( scope ) ;
262
+ var ctrl = element . controller ( 'ngModel' ) ;
262
263
263
- expect ( element ) . toBeDefined ( ) ;
264
- expect ( element . attr ( 'class' ) ) . toEqual (
265
- 'ng-pristine ng-untouched ng-valid ng-scope'
266
- ) ;
264
+ expect ( ctrl . $pristine ) . toBe ( true ) ;
265
+ expect ( ctrl . $valid ) . toBe ( true ) ;
267
266
268
267
var value = 'baz' ;
269
268
codemirror . setValue ( value ) ;
269
+ scope . $apply ( ) ;
270
270
expect ( scope . foo ) . toBe ( value ) ;
271
271
272
- expect ( element . attr ( 'class' ) ) . toEqual (
273
- 'ng-untouched ng-valid ng-scope ng-dirty ng-valid-parse'
274
- ) ;
272
+ expect ( ctrl . $valid ) . toBe ( true ) ;
273
+ expect ( ctrl . $dirty ) . toBe ( true ) ;
275
274
276
275
} ) ;
277
276
278
277
it ( 'when the model changes should update the IDE' , function ( ) {
279
278
var element = $compile ( '<div ui-codemirror ng-model="foo"></div>' ) ( scope ) ;
279
+ var ctrl = element . controller ( 'ngModel' ) ;
280
280
281
- expect ( element ) . toBeDefined ( ) ;
282
- expect ( element . attr ( 'class' ) ) . toEqual (
283
- 'ng-pristine ng-untouched ng-valid ng-scope'
284
- ) ;
281
+ expect ( ctrl . $pristine ) . toBe ( true ) ;
282
+ expect ( ctrl . $valid ) . toBe ( true ) ;
285
283
286
284
scope . $apply ( 'foo = "bar"' ) ;
287
285
expect ( codemirror . getValue ( ) ) . toBe ( scope . foo ) ;
288
286
289
- expect ( element . attr ( 'class' ) ) . toEqual (
290
- 'ng-pristine ng-untouched ng-valid ng-scope'
291
- ) ;
287
+ expect ( ctrl . $pristine ) . toBe ( true ) ;
288
+ expect ( ctrl . $valid ) . toBe ( true ) ;
292
289
} ) ;
293
290
294
291
0 commit comments