bootstrap-popover.js 2.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$(function () {

    module("bootstrap-popover")

      test("should be defined on jquery object", function () {
        var div = $('<div></div>')
        ok(div.popover, 'popover method is defined')
      })

      test("should return element", function () {
        var div = $('<div></div>')
        ok(div.popover() == div, 'document.body returned')
      })

      test("should render popover element", function () {
        $.support.transition = false
Jacob Thornton's avatar
Jacob Thornton committed
17
        var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
18
19
          .appendTo('#qunit-runoff')
          .popover()
Jacob Thornton's avatar
Jacob Thornton committed
20
          .popover('show')
21
22

        ok($('.popover').length, 'popover was inserted')
Jacob Thornton's avatar
Jacob Thornton committed
23
        popover.popover('hide')
24
25
26
27
28
29
        ok(!$(".popover").length, 'popover removed')
        $('#qunit-runoff').empty()
      })

      test("should store popover instance in popover data object", function () {
        $.support.transition = false
Jacob Thornton's avatar
Jacob Thornton committed
30
        var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
31
32
33
34
35
36
37
38
39
40
          .popover()

        ok(!!popover.data('popover'), 'popover instance exists')
      })

      test("should get title and content from options", function () {
        $.support.transition = false
        var popover = $('<a href="#">@fat</a>')
          .appendTo('#qunit-runoff')
          .popover({
Jacob Thornton's avatar
Jacob Thornton committed
41
42
43
44
45
46
            title: function () {
              return '@fat'
            }
          , content: function () {
              return 'loves writing tests (╯°□°)╯︵ ┻━┻'
            }
47
          })
Jacob Thornton's avatar
Jacob Thornton committed
48
49

        popover.popover('show')
50
51
52
53
54

        ok($('.popover').length, 'popover was inserted')
        equals($('.popover .title').text(), '@fat', 'title correctly inserted')
        equals($('.popover .content').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted')

Jacob Thornton's avatar
Jacob Thornton committed
55
        popover.popover('hide')
56
57
58
59
60
61
        ok(!$('.popover').length, 'popover was removed')
        $('#qunit-runoff').empty()
      })

      test("should get title and content from attributes", function () {
        $.support.transition = false
Jacob Thornton's avatar
Jacob Thornton committed
62
        var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
63
64
          .appendTo('#qunit-runoff')
          .popover()
Jacob Thornton's avatar
Jacob Thornton committed
65
          .popover('show')
66
67
68
69
70

        ok($('.popover').length, 'popover was inserted')
        equals($('.popover .title').text(), '@mdo', 'title correctly inserted')
        equals($('.popover .content').text(), "loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻", 'content correctly inserted')

Jacob Thornton's avatar
Jacob Thornton committed
71
        popover.popover('hide')
72
73
74
75
76
        ok(!$('.popover').length, 'popover was removed')
        $('#qunit-runoff').empty()
      })

})