| Server IP : 172.67.216.113 / Your IP : 172.71.28.145 [ 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('api', function() {
// Override the options
$.extend($.fn.bootstrapValidator.DEFAULT_OPTIONS, {
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
}
});
beforeEach(function() {
$([
'<form class="form-horizontal" id="apiForm">',
'<div class="form-group">',
'<input type="text" name="username" data-bv-notempty data-bv-stringlength data-bv-stringlength-min="8" />',
'</div>',
'<div class="form-group">',
'<input type="text" name="email" data-bv-notempty data-bv-emailaddress />',
'</div>',
'<div class="form-group">',
'<input type="text" name="note"/>',
'</div>',
'</form>'
].join('\n')).appendTo('body');
$('#apiForm').bootstrapValidator();
this.bv = $('#apiForm').data('bootstrapValidator');
this.$email = this.bv.getFieldElements('email');
this.$note = $('#apiForm').find('input[name="note"]');
});
afterEach(function() {
$('#apiForm').bootstrapValidator('destroy').remove();
});
it('revalidateField()', function() {
this.$email.val('[email protected]');
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('destroy()', function() {
this.bv.destroy();
expect($('#apiForm').data('bootstrapValidator')).toBeUndefined();
expect($('#apiForm').find('i[data-bv-icon-for]').length).toEqual(0);
expect($('#apiForm').find('.help-block[data-bv-for]').length).toEqual(0);
expect($('#apiForm').find('.has-feedback').length).toEqual(0);
expect($('#apiForm').find('.has-success').length).toEqual(0);
expect($('#apiForm').find('.has-error').length).toEqual(0);
expect($('#apiForm').find('[data-bv-field]').length).toEqual(0);
});
it('getOptions()', function() {
// Form options
expect(this.bv.getOptions().feedbackIcons.valid).toEqual('glyphicon glyphicon-ok');
// Field options
expect(this.bv.getOptions('username', 'stringlength')).toBeNull();
expect(this.bv.getOptions('username', 'stringlength', 'min')).toBeNull();
expect(this.bv.getOptions('username', 'stringLength')).toBeDefined();
expect(this.bv.getOptions('username', 'stringLength', 'min')).toEqual('8');
expect(this.bv.getOptions('username', 'stringlength', 'max')).toBeNull();
});
// #1014
it('isValidField()', function() {
this.$email.val('[email protected]');
this.bv.validate();
expect(this.bv.isValidField(this.$note)).toBeTruthy();
expect(this.bv.isValidField(this.$email)).toBeTruthy();
});
// #1014
it('validateField()', function() {
this.$email.val('[email protected]');
this.bv.validateField(this.$email);
this.bv.validateField(this.$note);
expect(this.bv.isValidField(this.$email)).toBeTruthy();
expect(this.bv.isValidField(this.$note)).toBeTruthy();
});
});