api.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. describe('api', function() {
  2. // Override the options
  3. $.extend($.fn.bootstrapValidator.DEFAULT_OPTIONS, {
  4. feedbackIcons: {
  5. valid: 'glyphicon glyphicon-ok',
  6. invalid: 'glyphicon glyphicon-remove',
  7. validating: 'glyphicon glyphicon-refresh'
  8. }
  9. });
  10. beforeEach(function() {
  11. $([
  12. '<div class="container">',
  13. '<form class="form-horizontal" id="apiForm">',
  14. '<div class="form-group">',
  15. '<input type="text" name="username" data-bv-notempty />',
  16. '</div>',
  17. '<div class="form-group">',
  18. '<input type="text" name="email" data-bv-emailaddress />',
  19. '</div>',
  20. '</form>',
  21. '</div>'
  22. ].join('\n')).appendTo('body');
  23. $('#apiForm').bootstrapValidator();
  24. this.bv = $('#apiForm').data('bootstrapValidator');
  25. this.$email = this.bv.getFieldElements('email');
  26. });
  27. afterEach(function() {
  28. $('#apiForm').bootstrapValidator('destroy').parent().remove();
  29. });
  30. it('destroy', function() {
  31. this.bv.destroy();
  32. expect($('#apiForm').data('bootstrapValidator')).toBeUndefined();
  33. expect($('#apiForm').find('i[data-bv-icon-for]').length).toEqual(0);
  34. expect($('#apiForm').find('.help-block[data-bv-for]').length).toEqual(0);
  35. expect($('#apiForm').find('.has-feedback').length).toEqual(0);
  36. expect($('#apiForm').find('.has-success').length).toEqual(0);
  37. expect($('#apiForm').find('.has-error').length).toEqual(0);
  38. expect($('#apiForm').find('[data-bv-field]').length).toEqual(0);
  39. });
  40. });