1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-10-02 00:06:46 +02:00

more tests, more js goodness

This commit is contained in:
Jacob Thornton
2011-09-10 12:49:21 -07:00
parent 79d5f90713
commit 48aa209348
9 changed files with 206 additions and 34 deletions

View File

@@ -3,30 +3,54 @@ $(function () {
module("bootstrap-modal")
test("should be defined on jquery object", function () {
ok($(document.body).modal, 'modal method is defined')
var div = $("<div id='modal-test'></div>")
ok(div.modal, 'modal method is defined')
})
test("should not return element", function () {
ok(!$(document.body).modal()[0], 'document.body not returned')
test("should return element", function () {
var div = $("<div id='modal-test'></div>")
ok(div.modal() == div, 'document.body 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", function () {
ok($.fn.modal.defaults, 'default object exposed')
})
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 insert into dom when modal:show event is called", function () {
$.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()
})
test("should remove from dom when close is called", function () {
$.support.transition = false
re
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()
})
test("should remove from dom when click .close")
test("should toggle when toggle is called", function () {
$.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()
})
test("should remove from dom when click .close", function () {
$.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()
})
})