|
|
@@ -10,16 +10,14 @@ describe('api', function() {
|
|
|
|
|
|
beforeEach(function() {
|
|
|
$([
|
|
|
- '<div class="container">',
|
|
|
- '<form class="form-horizontal" id="apiForm">',
|
|
|
- '<div class="form-group">',
|
|
|
- '<input type="text" name="username" data-bv-notempty />',
|
|
|
- '</div>',
|
|
|
- '<div class="form-group">',
|
|
|
- '<input type="text" name="email" data-bv-emailaddress />',
|
|
|
- '</div>',
|
|
|
- '</form>',
|
|
|
- '</div>'
|
|
|
+ '<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>',
|
|
|
+ '</form>'
|
|
|
].join('\n')).appendTo('body');
|
|
|
|
|
|
$('#apiForm').bootstrapValidator();
|
|
|
@@ -29,10 +27,10 @@ describe('api', function() {
|
|
|
});
|
|
|
|
|
|
afterEach(function() {
|
|
|
- $('#apiForm').bootstrapValidator('destroy').parent().remove();
|
|
|
+ $('#apiForm').bootstrapValidator('destroy').remove();
|
|
|
});
|
|
|
|
|
|
- it('call revalidateField()', function() {
|
|
|
+ it('revalidateField()', function() {
|
|
|
this.$email.val('email@domain.com');
|
|
|
this.bv.validate();
|
|
|
expect(this.bv.isValidField('email')).toBeTruthy();
|
|
|
@@ -42,7 +40,7 @@ describe('api', function() {
|
|
|
expect(this.bv.isValidField(this.$email)).toEqual(false);
|
|
|
});
|
|
|
|
|
|
- it('call destroy()', function() {
|
|
|
+ it('destroy()', function() {
|
|
|
this.bv.destroy();
|
|
|
expect($('#apiForm').data('bootstrapValidator')).toBeUndefined();
|
|
|
expect($('#apiForm').find('i[data-bv-icon-for]').length).toEqual(0);
|
|
|
@@ -52,6 +50,19 @@ describe('api', function() {
|
|
|
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();
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
describe('container form option', function() {
|