bootstrap-modal.js 1.99 KB
Newer Older
1
2
3
4
5
$(function () {

    module("bootstrap-modal")

      test("should be defined on jquery object", function () {
Jacob Thornton's avatar
Jacob Thornton committed
6
7
        var div = $("<div id='modal-test'></div>")
        ok(div.modal, 'modal method is defined')
8
9
      })

Jacob Thornton's avatar
Jacob Thornton committed
10
11
12
      test("should return element", function () {
        var div = $("<div id='modal-test'></div>")
        ok(div.modal() == div, 'document.body returned')
13
14
      })

Jacob Thornton's avatar
Jacob Thornton committed
15
16
      test("should expose defaults var for settings", function () {
        ok($.fn.modal.defaults, 'default object exposed')
17
18
      })

Jacob Thornton's avatar
Jacob Thornton committed
19
20
21
22
23
24
      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()
25
26
      })

Jacob Thornton's avatar
Jacob Thornton committed
27
28
29
30
31
32
33
34
      test("should remove from dom when close 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.trigger("modal:hide")
        ok(!$('#modal-test').length, 'modal removed from dom')
        div.remove()
35
36
      })

Jacob Thornton's avatar
Jacob Thornton committed
37
      test("should toggle when toggle is called", function () {
38
        $.support.transition = false
Jacob Thornton's avatar
Jacob Thornton committed
39
40
41
42
43
44
        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()
45
46
      })

Jacob Thornton's avatar
Jacob Thornton committed
47
48
49
50
51
52
53
54
55
      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()
      })
56
})