Removes copied dependencies, bootstrap unit tests, custom scrollbars.
[profile/ivi/cowhide.git] / tests / unit / cowhide-button.js
1 $(function () {
2
3     module("cowhide-button", {
4       setup: function() {
5         // Resets the driving state
6         $.cowhide.setDrivingMode(false)
7       }
8     })
9
10       test("should be disabled when driving", function () {
11         var page = $('<div class="page"></div>')
12         var btn = $('<button class="btn">test</button>')
13         btn.appendTo(page)
14         btn.ch_button()
15         $.cowhide.setDrivingMode(true)
16         stop()
17         setTimeout(function () {
18           ok(btn.attr('disabled'), 'btn is disabled')
19           ok(btn.hasClass('disabled'), 'btn has disabled class')
20           start()
21         }, 0)
22       })
23
24       test("should support ignore-driving-mode", function () {
25         var page = $('<div class="page"></div>')
26         var btn = $('<button class="btn" data-ignore-driving-mode="true">test</button>')
27         btn.appendTo(page)
28         btn.ch_button()
29         $.cowhide.setDrivingMode(true)
30         stop()
31         setTimeout(function () {
32           ok(!btn.attr('disabled'), 'btn is disabled')
33           ok(!btn.hasClass('disabled'), 'btn has disabled class')
34           start()
35         }, 0)
36       })
37
38
39       test("should have marquee element if marquee is enabled", function() {
40         var page = $('<div class="page"></div>')
41         var btn = $('<button class="btn" data-marquee="true">this is some really long text, for a button, is it not?</button>')
42         btn.appendTo(page)
43         btn.ch_button()
44         stop()
45         setTimeout(function () {
46           equal(btn.find('marquee').length, 1, 'marquee tag is present')
47           start()
48         }, 0)
49       })
50
51       test("marquee should be removed when driving", function() {
52         var page = $('<div class="page"></div>')
53         var btn = $('<button class="btn" data-marquee="true">test</button>')
54         btn.appendTo(page)
55         btn.ch_button('marquee')
56         $.cowhide.setDrivingMode(true)
57         stop()
58         setTimeout(function () {
59           equal(btn.find('marquee').length, 0, 'marquee tag is missing')
60           start()
61         }, 0)
62       })
63
64       test("marquee should be enabled again when driving stops", function() {
65         var page = $('<div class="page"></div>')
66         var btn = $('<button class="btn" data-marquee="true">test</button>')
67         btn.appendTo(page)
68         btn.ch_button('marquee')
69         $.cowhide.setDrivingMode(true)
70         $.cowhide.setDrivingMode(false)
71         stop()
72         setTimeout(function () {
73           equal(btn.find('marquee').length, 1, 'marquee tag is present')
74           start()
75         }, 0)
76       })
77
78       test("should respect fixed width requirement", function() {
79         var page = $('<div class="page"></div>')
80         var btn = $('<button class="btn" data-fixed-width="200">this is some really long text, for a button, is it not?</button>')
81         btn.appendTo(page)
82         btn.ch_button()
83         stop()
84         setTimeout(function () {
85           equal(btn.css('width'), '200px', 'width is 200px')
86           start()
87         }, 0)
88       })
89
90       test("should respect minimum font size requirement", function() {
91         var page = $('<div class="page"></div>')
92         var btn = $('<button class="btn">test</button>')
93         btn.appendTo(page)
94         btn.ch_button()
95         btn.css('font-size', '1px');
96         raises(function() {
97           $.cowhide.verifyFrameworkRestrictions()
98         }, Error, "core throws Error")
99       })
100
101       test("should respect maximum font size requirement", function() {
102         var page = $('<div class="page"></div>')
103         var btn = $('<button class="btn">test</button>')
104         btn.appendTo(page)
105         btn.ch_button()
106         btn.css('font-size', '100px');
107         raises(function() {
108           $.cowhide.verifyFrameworkRestrictions()
109         }, Error, "core throws Error")
110       })
111 })