mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-28 15:50:01 +02:00
move js plugins to root dir, begin writing tests, and change modal plugin to be more boss like
This commit is contained in:
41
js/tests/unit/bootstrap-alerts.js
vendored
Normal file
41
js/tests/unit/bootstrap-alerts.js
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-alerts")
|
||||
|
||||
test("should be defined on jquery object", function () {
|
||||
ok($(document.body).alert, 'alert method is defined')
|
||||
})
|
||||
|
||||
test("should return element", function () {
|
||||
ok($(document.body).alert()[0] == document.body, 'document.body returned')
|
||||
})
|
||||
|
||||
test("should fade element out on clicking .close", function () {
|
||||
var alertHTML = '<div class="alert-message warning fade in">'
|
||||
+ '<a class="close" href="#">×</a>'
|
||||
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you’re not looking too good.</p>'
|
||||
+ '</div>'
|
||||
, alert = $(alertHTML).alert()
|
||||
|
||||
alert.find('.close').click()
|
||||
|
||||
ok(!alert.hasClass('in'), 'remove .in class on .close click')
|
||||
})
|
||||
|
||||
test("should remove element when clicking .close", function () {
|
||||
$.support.transition = false
|
||||
|
||||
var alertHTML = '<div class="alert-message warning fade in">'
|
||||
+ '<a class="close" href="#">×</a>'
|
||||
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you’re not looking too good.</p>'
|
||||
+ '</div>'
|
||||
, alert = $(alertHTML).appendTo('#qunit-runoff').alert()
|
||||
|
||||
ok($('#qunit-runoff').find('.alert-message').length, 'element added to dom')
|
||||
|
||||
alert.find('.close').click()
|
||||
|
||||
ok(!$('#qunit-runoff').find('.alert-message').length, 'element removed from dom')
|
||||
})
|
||||
|
||||
})
|
52
js/tests/unit/bootstrap-dropdown.js
vendored
Normal file
52
js/tests/unit/bootstrap-dropdown.js
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-dropdowns")
|
||||
|
||||
test("should be defined on jquery object", function () {
|
||||
ok($(document.body).dropdown, 'dropdown method is defined')
|
||||
})
|
||||
|
||||
test("should return element", function () {
|
||||
ok($(document.body).dropdown()[0] == document.body, 'document.body returned')
|
||||
})
|
||||
|
||||
test("should add class open to menu if clicked", function () {
|
||||
var dropdownHTML = '<ul class="tabs">'
|
||||
+ '<li class="dropdown">'
|
||||
+ '<a href="#" class="dropdown-toggle">Dropdown</a>'
|
||||
+ '<ul class="dropdown-menu">'
|
||||
+ '<li><a href="#">Secondary link</a></li>'
|
||||
+ '<li><a href="#">Something else here</a></li>'
|
||||
+ '<li class="divider"></li>'
|
||||
+ '<li><a href="#">Another link</a></li>'
|
||||
+ '</ul>'
|
||||
+ '</li>'
|
||||
+ '</ul>'
|
||||
, dropdown = $(dropdownHTML).dropdown()
|
||||
|
||||
dropdown.find('.dropdown-toggle').click()
|
||||
ok(dropdown.find('.dropdown').hasClass('open'), 'open class added on click')
|
||||
})
|
||||
|
||||
test("should remove open class if body clicked", function () {
|
||||
var dropdownHTML = '<ul class="tabs">'
|
||||
+ '<li class="dropdown">'
|
||||
+ '<a href="#" class="dropdown-toggle">Dropdown</a>'
|
||||
+ '<ul class="dropdown-menu">'
|
||||
+ '<li><a href="#">Secondary link</a></li>'
|
||||
+ '<li><a href="#">Something else here</a></li>'
|
||||
+ '<li class="divider"></li>'
|
||||
+ '<li><a href="#">Another link</a></li>'
|
||||
+ '</ul>'
|
||||
+ '</li>'
|
||||
+ '</ul>'
|
||||
, dropdown = $(dropdownHTML).dropdown().appendTo('#qunit-runoff')
|
||||
|
||||
dropdown.find('.dropdown-toggle').click()
|
||||
ok(dropdown.find('.dropdown').hasClass('open'), 'open class added on click')
|
||||
$('body').click()
|
||||
ok(!dropdown.find('.dropdown').hasClass('open'), 'open class removed')
|
||||
dropdown.remove()
|
||||
})
|
||||
|
||||
})
|
32
js/tests/unit/bootstrap-modal.js
vendored
Normal file
32
js/tests/unit/bootstrap-modal.js
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-modal")
|
||||
|
||||
test("should be defined on jquery object", function () {
|
||||
ok($(document.body).modal, 'modal method is defined')
|
||||
})
|
||||
|
||||
test("should not return element", function () {
|
||||
ok(!$(document.body).modal()[0], 'document.body not returned')
|
||||
})
|
||||
|
||||
test("should return instance of modal class", function () {
|
||||
ok($(document.body).modal() instanceof $.fn.modal.Modal, 'document.body returned')
|
||||
})
|
||||
|
||||
test("should expose defaults var for settings", {
|
||||
ok(!!$.fn.modal.default, 'default object exposed')
|
||||
})
|
||||
|
||||
test("should insert into dom when open is called", function () {
|
||||
var div = $("<div></div>")
|
||||
div.modal().open()
|
||||
})
|
||||
|
||||
test("should remove from dom when close is called", function () {
|
||||
$.support.transition = false
|
||||
re
|
||||
})
|
||||
|
||||
test("should remove from dom when click .close")
|
||||
})
|
0
js/tests/unit/bootstrap-popover.js
vendored
Normal file
0
js/tests/unit/bootstrap-popover.js
vendored
Normal file
0
js/tests/unit/bootstrap-tabs.js
vendored
Normal file
0
js/tests/unit/bootstrap-tabs.js
vendored
Normal file
0
js/tests/unit/bootstrap-twipsy.js
vendored
Normal file
0
js/tests/unit/bootstrap-twipsy.js
vendored
Normal file
Reference in New Issue
Block a user