|
|
@@ -364,8 +364,8 @@ describe('event field programmatically', function() {
|
|
|
// Modifying default events
|
|
|
// ---
|
|
|
|
|
|
-describe('event form trigger with default events', function () {
|
|
|
- beforeEach(function () {
|
|
|
+describe('event form trigger with default events', function() {
|
|
|
+ beforeEach(function() {
|
|
|
$([
|
|
|
'<form class="form-horizontal" id="eventForm1">',
|
|
|
'<div id="msg"></div>',
|
|
|
@@ -377,55 +377,54 @@ describe('event form trigger with default events', function () {
|
|
|
|
|
|
$('#eventForm1')
|
|
|
.bootstrapValidator()
|
|
|
- .on('bv.form.success', function (e) {
|
|
|
+ .on('bv.form.success', function(e) {
|
|
|
$('#msg').html('form ' + $(e.target).attr('id') + ' triggered bv.form.success event');
|
|
|
})
|
|
|
- .on('success.form.bv', function (e) {
|
|
|
+ .on('success.form.bv', function(e) {
|
|
|
$('#msg').html('form ' + $(e.target).attr('id') + ' triggered success.form.bv event');
|
|
|
})
|
|
|
- .on('bv.form.error', function (e) {
|
|
|
+ .on('bv.form.error', function(e) {
|
|
|
$('#msg').html('form ' + $(e.target).attr('id') + ' triggered bv.form.error event');
|
|
|
})
|
|
|
- .on('error.form.bv', function (e) {
|
|
|
+ .on('error.form.bv', function(e) {
|
|
|
$('#msg').html('form ' + $(e.target).attr('id') + ' triggered error.form.bv event');
|
|
|
});
|
|
|
|
|
|
- this.bv = $('#eventForm1').data('bootstrapValidator');
|
|
|
+ this.bv = $('#eventForm1').data('bootstrapValidator');
|
|
|
this.$email = this.bv.getFieldElements('email');
|
|
|
});
|
|
|
|
|
|
- afterEach(function () {
|
|
|
+ afterEach(function() {
|
|
|
$('#eventForm1').bootstrapValidator('destroy').remove();
|
|
|
});
|
|
|
|
|
|
- it('does not trigger bv.form.success', function () {
|
|
|
+ it('does not trigger bv.form.success', function() {
|
|
|
this.$email.val('email@domain.com');
|
|
|
this.bv.validate();
|
|
|
expect($('#msg').html()).not.toEqual('form eventForm1 triggered bv.form.success event');
|
|
|
});
|
|
|
|
|
|
- it('triggers success.form.bv', function () {
|
|
|
+ it('triggers success.form.bv', function() {
|
|
|
this.$email.val('email@domain.com');
|
|
|
this.bv.validate();
|
|
|
expect($('#msg').html()).toEqual('form eventForm1 triggered success.form.bv event');
|
|
|
});
|
|
|
|
|
|
- it('does not trigger bv.form.error', function () {
|
|
|
+ it('does not trigger bv.form.error', function() {
|
|
|
this.$email.val('email@domain');
|
|
|
this.bv.validate();
|
|
|
expect($('#msg').html()).not.toEqual('form eventForm1 triggered bv.form.error event');
|
|
|
});
|
|
|
|
|
|
- it('triggers error.form.bv', function () {
|
|
|
+ it('triggers error.form.bv', function() {
|
|
|
this.$email.val('email@domain');
|
|
|
this.bv.validate();
|
|
|
expect($('#msg').html()).toEqual('form eventForm1 triggered error.form.bv event');
|
|
|
-
|
|
|
});
|
|
|
});
|
|
|
|
|
|
-describe('event field trigger with default events', function () {
|
|
|
- beforeEach(function () {
|
|
|
+describe('event field trigger with default events', function() {
|
|
|
+ beforeEach(function() {
|
|
|
$([
|
|
|
'<form class="form-horizontal" id="eventForm3">',
|
|
|
'<div id="msg"></div>',
|
|
|
@@ -437,54 +436,54 @@ describe('event field trigger with default events', function () {
|
|
|
|
|
|
$('#eventForm3')
|
|
|
.bootstrapValidator()
|
|
|
- .on('success.field.bv', '[name="email"]', function (e, data) {
|
|
|
+ .on('success.field.bv', '[name="email"]', function(e, data) {
|
|
|
$('#msg').html('triggered success.field.bv on ' + data.field);
|
|
|
})
|
|
|
- .on('error.field.bv', '[name="email"]', function (e, data) {
|
|
|
+ .on('error.field.bv', '[name="email"]', function(e, data) {
|
|
|
$('#msg').html('triggered error.field.bv on ' + data.field);
|
|
|
})
|
|
|
- .on('bv.field.success', '[name="email"]', function (e, data) {
|
|
|
+ .on('bv.field.success', '[name="email"]', function(e, data) {
|
|
|
$('#msg').html('triggered bv.field.success on ' + data.field);
|
|
|
})
|
|
|
- .on('bv.field.error', '[name="email"]', function (e, data) {
|
|
|
+ .on('bv.field.error', '[name="email"]', function(e, data) {
|
|
|
$('#msg').html('triggered bv.field.error on ' + data.field);
|
|
|
});
|
|
|
|
|
|
- this.bv = $('#eventForm3').data('bootstrapValidator');
|
|
|
+ this.bv = $('#eventForm3').data('bootstrapValidator');
|
|
|
this.$email = this.bv.getFieldElements('email');
|
|
|
});
|
|
|
|
|
|
- afterEach(function () {
|
|
|
+ afterEach(function() {
|
|
|
$('#eventForm3').bootstrapValidator('destroy').remove();
|
|
|
});
|
|
|
|
|
|
- it('triggers success.field.bv', function () {
|
|
|
+ it('triggers success.field.bv', function() {
|
|
|
this.$email.val('email@domain.com');
|
|
|
this.bv.validate();
|
|
|
expect($('#msg').html()).toEqual('triggered success.field.bv on email');
|
|
|
});
|
|
|
|
|
|
- it('does not trigger bv.field.success', function () {
|
|
|
+ it('does not trigger bv.field.success', function() {
|
|
|
this.$email.val('email@domain.com');
|
|
|
this.bv.validate();
|
|
|
expect($('#msg').html()).not.toEqual('triggered bv.field.success on email');
|
|
|
});
|
|
|
|
|
|
- it('does not trigger error.field.bv', function () {
|
|
|
+ it('does not trigger error.field.bv', function() {
|
|
|
this.$email.val('email@domain');
|
|
|
this.bv.validate();
|
|
|
expect($('#msg').html()).toEqual('triggered error.field.bv on email');
|
|
|
});
|
|
|
|
|
|
- it('triggers bv.field.error', function () {
|
|
|
+ it('triggers bv.field.error', function() {
|
|
|
this.$email.val('email@domain');
|
|
|
this.bv.validate();
|
|
|
expect($('#msg').html()).not.toEqual('triggered bv.field.error on email');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
-describe('event form trigger with events changed', function () {
|
|
|
- beforeEach(function () {
|
|
|
+describe('event form trigger with events changed', function() {
|
|
|
+ beforeEach(function() {
|
|
|
$.fn.bootstrapValidator.DEFAULT_OPTIONS = $.extend({}, $.fn.bootstrapValidator.DEFAULT_OPTIONS, {
|
|
|
events: {
|
|
|
formInit: 'init.form.bv',
|
|
|
@@ -512,40 +511,40 @@ describe('event form trigger with events changed', function () {
|
|
|
|
|
|
$('#eventForm2')
|
|
|
.bootstrapValidator()
|
|
|
- .on('bv.form.success', function (e) {
|
|
|
+ .on('bv.form.success', function(e) {
|
|
|
$('#msg').html('form ' + $(e.target).attr('id') + ' triggered bv.form.success event');
|
|
|
})
|
|
|
- .on('success.form.bv', function (e) {
|
|
|
+ .on('success.form.bv', function(e) {
|
|
|
$('#msg').html('form ' + $(e.target).attr('id') + ' triggered success.form.bv event');
|
|
|
})
|
|
|
- .on('bv.form.error', function (e) {
|
|
|
+ .on('bv.form.error', function(e) {
|
|
|
$('#msg').html('form ' + $(e.target).attr('id') + ' triggered bv.form.error event');
|
|
|
})
|
|
|
- .on('error.form.bv', function (e) {
|
|
|
+ .on('error.form.bv', function(e) {
|
|
|
$('#msg').html('form ' + $(e.target).attr('id') + ' triggered error.form.bv event');
|
|
|
});
|
|
|
|
|
|
- this.bv = $('#eventForm2').data('bootstrapValidator');
|
|
|
+ this.bv = $('#eventForm2').data('bootstrapValidator');
|
|
|
this.$email = this.bv.getFieldElements('email');
|
|
|
});
|
|
|
|
|
|
- afterEach(function () {
|
|
|
+ afterEach(function() {
|
|
|
$('#eventForm2').bootstrapValidator('destroy').remove();
|
|
|
});
|
|
|
|
|
|
- it('triggers bv.form.success', function () {
|
|
|
+ it('triggers bv.form.success', function() {
|
|
|
this.$email.val('email@domain.com');
|
|
|
this.bv.validate();
|
|
|
expect($('#msg').html()).toEqual('form eventForm2 triggered bv.form.success event');
|
|
|
});
|
|
|
|
|
|
- it('does not trigger success.form.bv', function () {
|
|
|
+ it('does not trigger success.form.bv', function() {
|
|
|
this.$email.val('email@domain.com');
|
|
|
this.bv.validate();
|
|
|
expect($('#msg').html()).not.toEqual('form eventForm2 triggered success.form.bv event');
|
|
|
});
|
|
|
|
|
|
- it('triggers bv.form.error', function () {
|
|
|
+ it('triggers bv.form.error', function() {
|
|
|
spyOn(window, 'onerror');
|
|
|
|
|
|
this.$email.val('email@domain');
|
|
|
@@ -556,7 +555,7 @@ describe('event form trigger with events changed', function () {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
-describe('event field trigger with events changed', function () {
|
|
|
+describe('event field trigger with events changed', function() {
|
|
|
beforeEach(function () {
|
|
|
$.fn.bootstrapValidator.DEFAULT_OPTIONS = $.extend({}, $.fn.bootstrapValidator.DEFAULT_OPTIONS, {
|
|
|
events: {
|
|
|
@@ -585,46 +584,46 @@ describe('event field trigger with events changed', function () {
|
|
|
|
|
|
$('#eventForm4')
|
|
|
.bootstrapValidator()
|
|
|
- .on('success.field.bv', '[name="email"]', function (e, data) {
|
|
|
+ .on('success.field.bv', '[name="email"]', function(e, data) {
|
|
|
$('#msg').html('triggered success.field.bv on ' + data.field);
|
|
|
})
|
|
|
- .on('error.field.bv', '[name="email"]', function (e, data) {
|
|
|
+ .on('error.field.bv', '[name="email"]', function(e, data) {
|
|
|
$('#msg').html('triggered error.field.bv on ' + data.field);
|
|
|
})
|
|
|
- .on('bv.field.success', '[name="email"]', function (e, data) {
|
|
|
+ .on('bv.field.success', '[name="email"]', function(e, data) {
|
|
|
$('#msg').html('triggered bv.field.success on ' + data.field);
|
|
|
})
|
|
|
- .on('bv.field.error', '[name="email"]', function (e, data) {
|
|
|
+ .on('bv.field.error', '[name="email"]', function(e, data) {
|
|
|
$('#msg').html('triggered bv.field.error on ' + data.field);
|
|
|
});
|
|
|
|
|
|
- this.bv = $('#eventForm4').data('bootstrapValidator');
|
|
|
+ this.bv = $('#eventForm4').data('bootstrapValidator');
|
|
|
this.$email = this.bv.getFieldElements('email');
|
|
|
});
|
|
|
|
|
|
- afterEach(function () {
|
|
|
+ afterEach(function() {
|
|
|
$('#eventForm4').bootstrapValidator('destroy').remove();
|
|
|
});
|
|
|
|
|
|
- it('triggers success.field.bv', function () {
|
|
|
+ it('triggers success.field.bv', function() {
|
|
|
this.$email.val('email@domain.com');
|
|
|
this.bv.validate();
|
|
|
expect($('#msg').html()).not.toEqual('triggered success.field.bv on email');
|
|
|
});
|
|
|
|
|
|
- it('does not trigger bv.field.success', function () {
|
|
|
+ it('does not trigger bv.field.success', function() {
|
|
|
this.$email.val('email@domain.com');
|
|
|
this.bv.validate();
|
|
|
expect($('#msg').html()).toEqual('triggered bv.field.success on email');
|
|
|
});
|
|
|
|
|
|
- it('does not trigger error.field.bv', function () {
|
|
|
+ it('does not trigger error.field.bv', function() {
|
|
|
this.$email.val('email@domain');
|
|
|
this.bv.validate();
|
|
|
expect($('#msg').html()).not.toEqual('triggered error.field.bv on email');
|
|
|
});
|
|
|
|
|
|
- it('triggers bv.field.error', function () {
|
|
|
+ it('triggers bv.field.error', function() {
|
|
|
spyOn(window, 'onerror');
|
|
|
|
|
|
this.$email.val('email@domain');
|