aboutsummaryrefslogtreecommitdiffstats
path: root/test/servicesSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/servicesSpec.js')
-rw-r--r--test/servicesSpec.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/test/servicesSpec.js b/test/servicesSpec.js
index 04aebce7..c0101098 100644
--- a/test/servicesSpec.js
+++ b/test/servicesSpec.js
@@ -150,22 +150,27 @@ describe("service", function(){
describe("$invalidWidgets", function(){
it("should count number of invalid widgets", function(){
- var scope = compile('<input name="price" ng:required ng:validate="number"></input>').$init();
+ var scope = compile('<input name="price" ng:required ng:validate="number"></input>');
+ jqLite(document.body).append(scope.$element);
+ scope.$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);
+ expect(scope.$invalidWidgets.length).toEqual(0);
jqLite(document.body).append(scope.$element);
- scope.$invalidWidgets.clearOrphans();
+ scope.price = 'abcd'; //force revalidation, maybe this should be done automatically?
+ scope.$eval();
expect(scope.$invalidWidgets.length).toEqual(1);
jqLite(document.body).html('');
- scope.$invalidWidgets.clearOrphans();
+ scope.$eval();
expect(scope.$invalidWidgets.length).toEqual(0);
});
});