input.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. describe('input', 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(done) {
  11. $([
  12. '<form class="form-horizontal" id="inputForm">',
  13. '<div class="form-group">',
  14. '<textarea name="text" data-bv-notempty placeholder="Text" />',
  15. '</div>',
  16. '<div class="form-group">',
  17. '<input type="text" name="input1" data-bv-notempty placeholder="Text" />',
  18. '</div>',
  19. '<div class="form-group">',
  20. '<input type="text" name="input2" data-bv-notempty placeholder="Café" />',
  21. '</div>',
  22. '</form>'
  23. ].join('\n')).appendTo('body');
  24. $('#inputForm').bootstrapValidator();
  25. this.bv = $('#inputForm').data('bootstrapValidator');
  26. this.$text = this.bv.getFieldElements('text');
  27. this.$input1 = this.bv.getFieldElements('input1');
  28. this.$input2 = this.bv.getFieldElements('input2');
  29. setTimeout(done, 0);
  30. });
  31. afterEach(function() {
  32. $('#inputForm').bootstrapValidator('destroy').remove();
  33. });
  34. // #1040
  35. it('fields should not be validated on init', function() {
  36. expect(this.bv.getMessages(this.$text)).toEqual([]);
  37. expect(this.bv.getMessages(this.$input1)).toEqual([]);
  38. expect(this.bv.getMessages(this.$input2)).toEqual([]);
  39. });
  40. });