mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-22 05:03:16 +02:00
add preventDefault support for all inital event types (show, close, hide, etc.) + fix small bug with scrollspy.last
This commit is contained in:
15
js/tests/unit/bootstrap-alert.js
vendored
15
js/tests/unit/bootstrap-alert.js
vendored
@@ -38,4 +38,19 @@ $(function () {
|
||||
ok(!$('#qunit-fixture').find('.alert-message').length, 'element removed from dom')
|
||||
})
|
||||
|
||||
test("should not fire closed when close is prevented", function () {
|
||||
$.support.transition = false
|
||||
stop();
|
||||
$('<div class="alert"/>')
|
||||
.bind('close', function (e) {
|
||||
e.preventDefault();
|
||||
ok(true);
|
||||
start();
|
||||
})
|
||||
.bind('closed', function () {
|
||||
ok(false);
|
||||
})
|
||||
.alert('close')
|
||||
})
|
||||
|
||||
})
|
28
js/tests/unit/bootstrap-carousel.js
vendored
Normal file
28
js/tests/unit/bootstrap-carousel.js
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-carousel")
|
||||
|
||||
test("should be defined on jquery object", function () {
|
||||
ok($(document.body).carousel, 'carousel method is defined')
|
||||
})
|
||||
|
||||
test("should return element", function () {
|
||||
ok($(document.body).carousel()[0] == document.body, 'document.body returned')
|
||||
})
|
||||
|
||||
test("should not fire sliden when slide is prevented", function () {
|
||||
$.support.transition = false
|
||||
stop();
|
||||
$('<div class="carousel"/>')
|
||||
.bind('slide', function (e) {
|
||||
e.preventDefault();
|
||||
ok(true);
|
||||
start();
|
||||
})
|
||||
.bind('slid', function () {
|
||||
ok(false);
|
||||
})
|
||||
.carousel('next')
|
||||
})
|
||||
|
||||
})
|
15
js/tests/unit/bootstrap-collapse.js
vendored
15
js/tests/unit/bootstrap-collapse.js
vendored
@@ -22,4 +22,19 @@ $(function () {
|
||||
ok(/height/.test(el.attr('style')), 'has height set')
|
||||
})
|
||||
|
||||
test("should not fire shown when show is prevented", function () {
|
||||
$.support.transition = false
|
||||
stop();
|
||||
$('<div class="collapse"/>')
|
||||
.bind('show', function (e) {
|
||||
e.preventDefault();
|
||||
ok(true);
|
||||
start();
|
||||
})
|
||||
.bind('shown', function () {
|
||||
ok(false);
|
||||
})
|
||||
.collapse('show')
|
||||
})
|
||||
|
||||
})
|
16
js/tests/unit/bootstrap-tab.js
vendored
16
js/tests/unit/bootstrap-tab.js
vendored
@@ -42,4 +42,20 @@ $(function () {
|
||||
equals($("#qunit-fixture").find('.active').attr('id'), "home")
|
||||
})
|
||||
|
||||
|
||||
test("should not fire closed when close is prevented", function () {
|
||||
$.support.transition = false
|
||||
stop();
|
||||
$('<div class="tab"/>')
|
||||
.bind('show', function (e) {
|
||||
e.preventDefault();
|
||||
ok(true);
|
||||
start();
|
||||
})
|
||||
.bind('shown', function () {
|
||||
ok(false);
|
||||
})
|
||||
.tab('show')
|
||||
})
|
||||
|
||||
})
|
Reference in New Issue
Block a user