Skip to content
This repository was archived by the owner on May 25, 2019. It is now read-only.

Commit 7188ecc

Browse files
committed
Merge pull request #80 from angular-ui/test-use-the-ngmodelcontroller
test: use ngmodelcontroller instead of relying on class names
2 parents d11f93d + 2f789f6 commit 7188ecc

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

test/codemirror.spec.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -259,36 +259,33 @@ describe('uiCodemirror', function() {
259259

260260
it('when the IDE changes should update the model', function() {
261261
var element = $compile('<div ui-codemirror ng-model="foo"></div>')(scope);
262+
var ctrl = element.controller('ngModel');
262263

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);
267266

268267
var value = 'baz';
269268
codemirror.setValue(value);
269+
scope.$apply();
270270
expect(scope.foo).toBe(value);
271271

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);
275274

276275
});
277276

278277
it('when the model changes should update the IDE', function() {
279278
var element = $compile('<div ui-codemirror ng-model="foo"></div>')(scope);
279+
var ctrl = element.controller('ngModel');
280280

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);
285283

286284
scope.$apply('foo = "bar"');
287285
expect(codemirror.getValue()).toBe(scope.foo);
288286

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);
292289
});
293290

294291

0 commit comments

Comments
 (0)