aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMisko Hevery2010-04-12 19:05:39 -0700
committerMisko Hevery2010-04-12 19:05:39 -0700
commit7c49b255483c0381c23de41d108800f93ebc1979 (patch)
tree09c841a413070e3c1eb6d69661f4a344f4a9d556 /test
parent713307b6505a56ca7b5423b36e297070d756ff15 (diff)
downloadangular.js-7c49b255483c0381c23de41d108800f93ebc1979.tar.bz2
$invalid widget clear on switch change
Diffstat (limited to 'test')
-rw-r--r--test/servicesSpec.js13
-rw-r--r--test/widgetsSpec.js5
2 files changed, 17 insertions, 1 deletions
diff --git a/test/servicesSpec.js b/test/servicesSpec.js
index 91cc1f0e..618d9a15 100644
--- a/test/servicesSpec.js
+++ b/test/servicesSpec.js
@@ -80,11 +80,22 @@ describe("service $invalidWidgets", function(){
});
it("should count number of invalid widgets", function(){
- var scope = compile('<input name="price" ng-required></input>').$init();
+ var scope = compile('<input name="price" ng-required ng-validate="number"></input>').$init();
expect(scope.$invalidWidgets.length).toEqual(1);
scope.price = 123;
scope.$eval();
expect(scope.$invalidWidgets.length).toEqual(0);
scope.$element.remove();
+ scope.price = 'abc';
+ scope.$eval();
+ expect(scope.$invalidWidgets.length).toEqual(1);
+
+ jqLite(document.body).append(scope.$element);
+ scope.$invalidWidgets.clearOrphans();
+ expect(scope.$invalidWidgets.length).toEqual(1);
+
+ jqLite(document.body).html('');
+ scope.$invalidWidgets.clearOrphans();
+ expect(scope.$invalidWidgets.length).toEqual(0);
});
});
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js
index c6158c37..c64f03ca 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -221,10 +221,15 @@ describe('ng:switch', function(){
it('should call init on switch', function(){
var scope = compile('<ng:switch on="url" change="name=\'works\'"><div ng-switch-when="a">{{name}}</div></ng:include>');
+ var cleared = false;
scope.url = 'a';
+ scope.$invalidWidgets = {clearOrphans: function(){
+ cleared = true;
+ }};
scope.$init();
expect(scope.name).toEqual(undefined);
expect(scope.$element.text()).toEqual('works');
+ expect(cleared).toEqual(true);
});
});