angular.js/test/service/invalidWidgetsSpec.js
Misko Hevery 8f0dcbab80 feat(scope): new and improved scope implementation
- Speed improvements (about 4x on flush phase)
- Memory improvements (uses no function closures)
- Break $eval into $apply, $dispatch, $flush
- Introduced $watch and $observe

Breaks angular.equals() use === instead of ==
Breaks angular.scope() does not take parent as first argument
Breaks scope.$watch() takes scope as first argument
Breaks scope.$set(), scope.$get are removed
Breaks scope.$config is removed
Breaks $route.onChange callback has not "this" bounded
2011-08-02 01:00:03 +02:00

41 lines
1 KiB
JavaScript

'use strict';
describe('$invalidWidgets', function() {
var scope;
beforeEach(function(){
scope = angular.scope();
});
afterEach(function(){
dealoc(scope);
});
it("should count number of invalid widgets", function(){
var element = jqLite('<input name="price" ng:required ng:validate="number">');
jqLite(document.body).append(element);
scope = compile(element)();
var $invalidWidgets = scope.$service('$invalidWidgets');
expect($invalidWidgets.length).toEqual(1);
scope.price = 123;
scope.$digest();
expect($invalidWidgets.length).toEqual(0);
scope.$element.remove();
scope.price = 'abc';
scope.$digest();
expect($invalidWidgets.length).toEqual(0);
jqLite(document.body).append(scope.$element);
scope.price = 'abcd'; //force revalidation, maybe this should be done automatically?
scope.$digest();
expect($invalidWidgets.length).toEqual(1);
jqLite(document.body).html('');
scope.$digest();
expect($invalidWidgets.length).toEqual(0);
});
});