1
0
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:
Jacob Thornton
2012-03-24 18:20:09 -07:00
parent ef5ac02b69
commit bccc2cb719
16 changed files with 128 additions and 32 deletions

View File

@@ -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
View 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')
})
})

View File

@@ -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')
})
})

View File

@@ -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')
})
})