Commit bcd5097c authored by Jacob Thornton's avatar Jacob Thornton

Merge pull request #3655 from jorgenfb/8dda8390

Updated unit test for tooltips. Now using is() instead of hasClass()
parents 7875e483 8dda8390
...@@ -84,9 +84,9 @@ ...@@ -84,9 +84,9 @@
, leave: function (e) { , leave: function (e) {
var self = $(e.currentTarget)[this.type](this._options).data(this.type) var self = $(e.currentTarget)[this.type](this._options).data(this.type)
if (this.timeout) clearTimeout(this.timeout)
if (!self.options.delay || !self.options.delay.hide) return self.hide() if (!self.options.delay || !self.options.delay.hide) return self.hide()
clearTimeout(this.timeout)
self.hoverState = 'out' self.hoverState = 'out'
this.timeout = setTimeout(function() { this.timeout = setTimeout(function() {
if (self.hoverState == 'out') self.hide() if (self.hoverState == 'out') self.hide()
......
...@@ -33,7 +33,7 @@ $(function () { ...@@ -33,7 +33,7 @@ $(function () {
.tooltip({placement: 'bottom'}) .tooltip({placement: 'bottom'})
.tooltip('show') .tooltip('show')
ok($(".tooltip").hasClass('fade bottom in'), 'has correct classes applied') ok($(".tooltip").is('.fade.bottom.in'), 'has correct classes applied')
tooltip.tooltip('hide') tooltip.tooltip('hide')
}) })
...@@ -69,10 +69,29 @@ $(function () { ...@@ -69,10 +69,29 @@ $(function () {
tooltip.trigger('mouseenter') tooltip.trigger('mouseenter')
setTimeout(function () { setTimeout(function () {
ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in') ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
tooltip.trigger('mouseout') tooltip.trigger('mouseout')
setTimeout(function () { setTimeout(function () {
ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in') ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
start()
}, 200)
}, 100)
})
test("should not show tooltip if leave event occurs before delay expires, even if hide delay is 0", function () {
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
.appendTo('#qunit-fixture')
.tooltip({ delay: { show: 200, hide: 0} })
stop()
tooltip.trigger('mouseenter')
setTimeout(function () {
ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
tooltip.trigger('mouseout')
setTimeout(function () {
ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
start() start()
}, 200) }, 200)
}, 100) }, 100)
...@@ -85,10 +104,10 @@ $(function () { ...@@ -85,10 +104,10 @@ $(function () {
stop() stop()
tooltip.trigger('mouseenter') tooltip.trigger('mouseenter')
setTimeout(function () { setTimeout(function () {
ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in') ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
tooltip.trigger('mouseout') tooltip.trigger('mouseout')
setTimeout(function () { setTimeout(function () {
ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in') ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
start() start()
}, 100) }, 100)
}, 50) }, 50)
...@@ -101,9 +120,9 @@ $(function () { ...@@ -101,9 +120,9 @@ $(function () {
stop() stop()
tooltip.trigger('mouseenter') tooltip.trigger('mouseenter')
setTimeout(function () { setTimeout(function () {
ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in') ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
setTimeout(function () { setTimeout(function () {
ok(!$(".tooltip").hasClass('fade in'), 'tooltip has faded in') ok(!$(".tooltip").is('.fade.in'), 'tooltip has faded in')
start() start()
}, 200) }, 200)
}, 100) }, 100)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment