Vous êtes connecté en tant que anonymous Se Deconnecter
Browse code

final procedural project

ER authored on 13/04/2012 10:17:34
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,76 @@
1
+$(function () {
2
+
3
+    module("bootstrap-popover")
4
+
5
+      test("should be defined on jquery object", function () {
6
+        var div = $('<div></div>')
7
+        ok(div.popover, 'popover method is defined')
8
+      })
9
+
10
+      test("should return element", function () {
11
+        var div = $('<div></div>')
12
+        ok(div.popover() == div, 'document.body returned')
13
+      })
14
+
15
+      test("should render popover element", function () {
16
+        $.support.transition = false
17
+        var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
18
+          .appendTo('#qunit-runoff')
19
+          .popover()
20
+          .popover('show')
21
+
22
+        ok($('.popover').length, 'popover was inserted')
23
+        popover.popover('hide')
24
+        ok(!$(".popover").length, 'popover removed')
25
+        $('#qunit-runoff').empty()
26
+      })
27
+
28
+      test("should store popover instance in popover data object", function () {
29
+        $.support.transition = false
30
+        var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
31
+          .popover()
32
+
33
+        ok(!!popover.data('popover'), 'popover instance exists')
34
+      })
35
+
36
+      test("should get title and content from options", function () {
37
+        $.support.transition = false
38
+        var popover = $('<a href="#">@fat</a>')
39
+          .appendTo('#qunit-runoff')
40
+          .popover({
41
+            title: function () {
42
+              return '@fat'
43
+            }
44
+          , content: function () {
45
+              return 'loves writing tests (╯°□°)╯︵ ┻━┻'
46
+            }
47
+          })
48
+
49
+        popover.popover('show')
50
+
51
+        ok($('.popover').length, 'popover was inserted')
52
+        equals($('.popover .title').text(), '@fat', 'title correctly inserted')
53
+        equals($('.popover .content').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted')
54
+
55
+        popover.popover('hide')
56
+        ok(!$('.popover').length, 'popover was removed')
57
+        $('#qunit-runoff').empty()
58
+      })
59
+
60
+      test("should get title and content from attributes", function () {
61
+        $.support.transition = false
62
+        var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
63
+          .appendTo('#qunit-runoff')
64
+          .popover()
65
+          .popover('show')
66
+
67
+        ok($('.popover').length, 'popover was inserted')
68
+        equals($('.popover .title').text(), '@mdo', 'title correctly inserted')
69
+        equals($('.popover .content').text(), "loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻", 'content correctly inserted')
70
+
71
+        popover.popover('hide')
72
+        ok(!$('.popover').length, 'popover was removed')
73
+        $('#qunit-runoff').empty()
74
+      })
75
+
76
+})