mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-20 20:31:26 +02:00
add bootstrap-scrollspy
This commit is contained in:
68
js/tests/unit/bootstrap-modal.js
vendored
68
js/tests/unit/bootstrap-modal.js
vendored
@@ -17,40 +17,70 @@ $(function () {
|
||||
})
|
||||
|
||||
test("should insert into dom when modal:show event is called", function () {
|
||||
stop()
|
||||
$.support.transition = false
|
||||
var div = $("<div id='modal-test'></div>")
|
||||
div.modal().trigger("modal:show")
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
div.remove()
|
||||
div
|
||||
.modal()
|
||||
.trigger("modal:show")
|
||||
.bind("modal:shown", function () {
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
start()
|
||||
div.remove()
|
||||
})
|
||||
})
|
||||
|
||||
test("should remove from dom when close is called", function () {
|
||||
test("should remove from dom when modal:hide is called", function () {
|
||||
stop()
|
||||
$.support.transition = false
|
||||
var div = $("<div id='modal-test'></div>")
|
||||
div.modal().trigger("modal:show")
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
div.trigger("modal:hide")
|
||||
ok(!$('#modal-test').length, 'modal removed from dom')
|
||||
div.remove()
|
||||
div
|
||||
.modal()
|
||||
.trigger("modal:show")
|
||||
.bind("modal:shown", function () {
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
div.trigger("modal:hide")
|
||||
})
|
||||
.bind("modal:hidden", function() {
|
||||
ok(!$('#modal-test').length, 'modal removed from dom')
|
||||
start()
|
||||
div.remove()
|
||||
})
|
||||
})
|
||||
|
||||
test("should toggle when toggle is called", function () {
|
||||
stop()
|
||||
$.support.transition = false
|
||||
var div = $("<div id='modal-test'></div>")
|
||||
div.modal().trigger("modal:toggle")
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
div.trigger("modal:toggle")
|
||||
ok(!$('#modal-test').length, 'modal removed from dom')
|
||||
div.remove()
|
||||
div
|
||||
.modal()
|
||||
.trigger("modal:toggle")
|
||||
.bind("modal:shown", function () {
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
div.trigger("modal:toggle")
|
||||
})
|
||||
.bind("modal:hidden", function() {
|
||||
ok(!$('#modal-test').length, 'modal removed from dom')
|
||||
start()
|
||||
div.remove()
|
||||
})
|
||||
})
|
||||
|
||||
test("should remove from dom when click .close", function () {
|
||||
stop()
|
||||
$.support.transition = false
|
||||
var div = $("<div id='modal-test'><span class='close'></span></div>")
|
||||
div.modal().trigger("modal:toggle")
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
div.find('.close').click()
|
||||
ok(!$('#modal-test').length, 'modal removed from dom')
|
||||
div.remove()
|
||||
div
|
||||
.modal()
|
||||
.trigger("modal:toggle")
|
||||
.bind("modal:shown", function () {
|
||||
ok($('#modal-test').length, 'modal insterted into dom')
|
||||
div.find('.close').click()
|
||||
})
|
||||
.bind("modal:hidden", function() {
|
||||
ok(!$('#modal-test').length, 'modal removed from dom')
|
||||
start()
|
||||
div.remove()
|
||||
})
|
||||
})
|
||||
})
|
31
js/tests/unit/bootstrap-scrollspy.js
vendored
Normal file
31
js/tests/unit/bootstrap-scrollspy.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-scrollspy")
|
||||
|
||||
test("should be defined on jquery object", function () {
|
||||
ok($(document.body).scrollspy, 'scrollspy method is defined')
|
||||
})
|
||||
|
||||
test("should return element", function () {
|
||||
ok($(document.body).scrollspy()[0] == document.body, 'document.body returned')
|
||||
})
|
||||
|
||||
test("should switch active class on scroll", function () {
|
||||
var sectionHTML = '<div id="masthead"></div>'
|
||||
, $section = $(sectionHTML).append('#qunit-runoff')
|
||||
, topbarHTML ='<div class="topbar">'
|
||||
+ '<div class="topbar-inner">'
|
||||
+ '<div class="container">'
|
||||
+ '<h3><a href="#">Bootstrap</a></h3>'
|
||||
+ '<ul class="nav">'
|
||||
+ '<li><a href="#masthead">Overview</a></li>'
|
||||
+ '</ul>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
, $topbar = $(topbarHTML).topbar()
|
||||
|
||||
ok(topbar.find('.active', true)
|
||||
})
|
||||
|
||||
})
|
Reference in New Issue
Block a user