| Server IP : 172.67.216.113 / Your IP : 104.23.243.32 [ Web Server : Apache System : Linux cpanel01wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.59.el6.x86_64 #1 SMP Thu Dec 6 05:11:00 EST 2018 x86_64 User : cp648411 ( 1354) PHP Version : 7.2.34 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home2/cp648411/public_html/kainumber.com/plugin/bootstrapvalidator-master/test/spec/ |
Upload File : |
describe('excluded', function() {
beforeEach(function() {
$([
'<div class="container">',
'<form class="form-horizontal" id="excludedForm" data-bv-excluded="[name=\'email\']">',
'<div class="form-group">',
'<input type="text" name="username" required />',
'</div>',
'<div class="form-group">',
'<input type="text" name="email" required data-bv-emailaddress />',
'</div>',
'</form>',
'</div>'
].join('')).appendTo('body');
$('#excludedForm').bootstrapValidator();
this.bv = $('#excludedForm').data('bootstrapValidator');
this.$username = this.bv.getFieldElements('username');
this.$email = this.bv.getFieldElements('email');
});
afterEach(function() {
$('#excludedForm').bootstrapValidator('destroy').parent().remove();
});
it('excluded form declarative', function() {
this.bv.validate();
expect(this.bv.isValid()).toEqual(false);
this.bv.resetForm();
this.$username.val('your_user_name');
this.$email.val('');
this.bv.validate();
expect(this.bv.isValid()).toBeTruthy();
});
it('excluded form programmatically', function() {
this.bv.destroy();
$('#excludedForm').removeAttr('data-bv-excluded');
$('#excludedForm').bootstrapValidator({
excluded: '[name="username"]'
});
this.bv = $('#excludedForm').data('bootstrapValidator');
this.$username = this.bv.getFieldElements('username');
this.$email = this.bv.getFieldElements('email');
this.$username.val('');
this.$email.val('invalid#email.com');
this.bv.validate();
expect(this.bv.isValid()).toEqual(false);
this.bv.resetForm();
this.$email.val('[email protected]');
this.bv.validate();
expect(this.bv.isValid()).toBeTruthy();
});
it('excluded field declarative', function() {
this.bv.destroy();
$('#excludedForm').removeAttr('data-bv-excluded');
$('#excludedForm').find('[name="username"]').attr('data-bv-excluded', 'true');
$('#excludedForm').find('[name="email"]').attr('data-bv-excluded', 'false');
this.bv = $('#excludedForm').bootstrapValidator().data('bootstrapValidator');
this.$username = this.bv.getFieldElements('username');
this.$email = this.bv.getFieldElements('email');
this.$username.val('');
this.$email.val('');
this.bv.validate();
expect(this.bv.isValid()).toEqual(false);
this.bv.resetForm();
this.$email.val('invalid#email.com');
this.bv.validate();
expect(this.bv.isValid()).toEqual(false);
this.bv.resetForm();
this.$email.val('[email protected]');
this.bv.validate();
expect(this.bv.isValid()).toBeTruthy();
});
it('excluded field programmatically true/false', function() {
this.bv.destroy();
$('#excludedForm').removeAttr('data-bv-excluded');
$('#excludedForm').bootstrapValidator({
fields: {
username: {
excluded: true
},
email: {
excluded: false
}
}
});
this.bv = $('#excludedForm').bootstrapValidator().data('bootstrapValidator');
this.$username = this.bv.getFieldElements('username');
this.$email = this.bv.getFieldElements('email');
this.$username.val('');
this.$email.val('');
this.bv.validate();
expect(this.bv.isValid()).toEqual(false);
this.bv.resetForm();
this.$email.val('invalid#email.com');
this.bv.validate();
expect(this.bv.isValid()).toEqual(false);
this.bv.resetForm();
this.$email.val('[email protected]');
this.bv.validate();
expect(this.bv.isValid()).toBeTruthy();
});
it('excluded field programmatically "true"/"false"', function() {
this.bv.destroy();
$('#excludedForm').removeAttr('data-bv-excluded');
$('#excludedForm').bootstrapValidator({
fields: {
username: {
excluded: 'false'
},
email: {
excluded: 'true'
}
}
});
this.bv = $('#excludedForm').bootstrapValidator().data('bootstrapValidator');
this.$username = this.bv.getFieldElements('username');
this.$email = this.bv.getFieldElements('email');
this.$username.val('');
this.$email.val('[email protected]');
this.bv.validate();
expect(this.bv.isValid()).toEqual(false);
this.bv.resetForm();
this.$username.val('your_user_name');
this.$email.val('invalid#email.com');
this.bv.validate();
expect(this.bv.isValid()).toBeTruthy();
});
});