Browse Source

#406: Add test suite for revalidateField() method

nghuuphuoc 11 years ago
parent
commit
c2dc307e88
2 changed files with 22 additions and 2 deletions
  1. 11 1
      test/spec.js
  2. 11 1
      test/spec/api.js

+ 11 - 1
test/spec.js

@@ -32,7 +32,17 @@ describe('api', function() {
         $('#apiForm').bootstrapValidator('destroy').parent().remove();
     });
 
-    it('destroy', function() {
+    it('call revalidateField()', function() {
+        this.$email.val('email@domain.com');
+        this.bv.validate();
+        expect(this.bv.isValidField('email')).toBeTruthy();
+
+        this.$email.val('invalid#email.address');
+        this.bv.revalidateField('email');
+        expect(this.bv.isValidField(this.$email)).toEqual(false);
+    });
+
+    it('call destroy()', function() {
         this.bv.destroy();
         expect($('#apiForm').data('bootstrapValidator')).toBeUndefined();
         expect($('#apiForm').find('i[data-bv-icon-for]').length).toEqual(0);

+ 11 - 1
test/spec/api.js

@@ -32,7 +32,17 @@ describe('api', function() {
         $('#apiForm').bootstrapValidator('destroy').parent().remove();
     });
 
-    it('destroy', function() {
+    it('call revalidateField()', function() {
+        this.$email.val('email@domain.com');
+        this.bv.validate();
+        expect(this.bv.isValidField('email')).toBeTruthy();
+
+        this.$email.val('invalid#email.address');
+        this.bv.revalidateField('email');
+        expect(this.bv.isValidField(this.$email)).toEqual(false);
+    });
+
+    it('call destroy()', function() {
         this.bv.destroy();
         expect($('#apiForm').data('bootstrapValidator')).toBeUndefined();
         expect($('#apiForm').find('i[data-bv-icon-for]').length).toEqual(0);