From b56d97f21065037523ec17f45685916df8aca678 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Tue, 20 Jan 2015 19:40:50 -0800 Subject: update JS unit tests to future-proof QUnit 1.16.0 API [skip validator] --- js/tests/unit/tooltip.js | 108 +++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 54 deletions(-) (limited to 'js/tests/unit/tooltip.js') diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 2264ca372..38298bdd8 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -115,37 +115,37 @@ $(function () { equal($('.tooltip').length, 0, 'tooltip removed') }) - test('should fire show event', function () { - stop() + test('should fire show event', function (assert) { + var done = assert.async() $('
') .on('show.bs.tooltip', function () { ok(true, 'show event fired') - start() + done() }) .bootstrapTooltip('show') }) - test('should fire shown event', function () { - stop() + test('should fire shown event', function (assert) { + var done = assert.async() $('
') .appendTo('#qunit-fixture') .on('shown.bs.tooltip', function () { ok(true, 'shown was called') - start() + done() }) .bootstrapTooltip('show') }) - test('should not fire shown event when show was prevented', function () { - stop() + test('should not fire shown event when show was prevented', function (assert) { + var done = assert.async() $('
') .on('show.bs.tooltip', function (e) { e.preventDefault() ok(true, 'show event fired') - start() + done() }) .on('shown.bs.tooltip', function () { ok(false, 'shown event fired') @@ -153,8 +153,8 @@ $(function () { .bootstrapTooltip('show') }) - test('should fire hide event', function () { - stop() + test('should fire hide event', function (assert) { + var done = assert.async() $('
') .appendTo('#qunit-fixture') @@ -163,13 +163,13 @@ $(function () { }) .on('hide.bs.tooltip', function () { ok(true, 'hide event fired') - start() + done() }) .bootstrapTooltip('show') }) - test('should fire hidden event', function () { - stop() + test('should fire hidden event', function (assert) { + var done = assert.async() $('
') .appendTo('#qunit-fixture') @@ -178,13 +178,13 @@ $(function () { }) .on('hidden.bs.tooltip', function () { ok(true, 'hidden event fired') - start() + done() }) .bootstrapTooltip('show') }) - test('should not fire hidden event when hide was prevented', function () { - stop() + test('should not fire hidden event when hide was prevented', function (assert) { + var done = assert.async() $('
') .appendTo('#qunit-fixture') @@ -194,7 +194,7 @@ $(function () { .on('hide.bs.tooltip', function (e) { e.preventDefault() ok(true, 'hide event fired') - start() + done() }) .on('hidden.bs.tooltip', function () { ok(false, 'hidden event fired') @@ -699,8 +699,8 @@ $(function () { ok(passed, '.tooltip(\'show\') should not throw an error if element no longer is in dom') }) - test('should place tooltip on top of element', function () { - stop() + test('should place tooltip on top of element', function (assert) { + var done = assert.async() var containerHTML = '
' + '

' @@ -732,12 +732,12 @@ $(function () { setTimeout(function () { ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) <= Math.round($trigger.offset().top)) - start() + done() }, 0) }) - test('should place tooltip inside viewport', function () { - stop() + test('should place tooltip inside viewport', function (assert) { + var done = assert.async() var $container = $('

') .css({ @@ -763,12 +763,12 @@ $(function () { setTimeout(function () { ok($('.tooltip').offset().left >= 0) - start() + done() }, 0) }) - test('should show tooltip if leave event hasn\'t occurred before delay expires', function () { - stop() + test('should show tooltip if leave event hasn\'t occurred before delay expires', function (assert) { + var done = assert.async() var $tooltip = $('') .appendTo('#qunit-fixture') @@ -780,14 +780,14 @@ $(function () { setTimeout(function () { ok($('.tooltip').is('.fade.in'), '200ms: tooltip is faded in') - start() + done() }, 200) $tooltip.trigger('mouseenter') }) - test('should not show tooltip if leave event occurs before delay expires', function () { - stop() + test('should not show tooltip if leave event occurs before delay expires', function (assert) { + var done = assert.async() var $tooltip = $('') .appendTo('#qunit-fixture') @@ -800,14 +800,14 @@ $(function () { setTimeout(function () { ok(!$('.tooltip').is('.fade.in'), '200ms: tooltip not faded in') - start() + done() }, 200) $tooltip.trigger('mouseenter') }) - test('should not hide tooltip if leave event occurs and enter event occurs within the hide delay', function () { - stop() + test('should not hide tooltip if leave event occurs and enter event occurs within the hide delay', function (assert) { + var done = assert.async() var $tooltip = $('') .appendTo('#qunit-fixture') @@ -824,15 +824,15 @@ $(function () { setTimeout(function () { ok($('.tooltip').is('.fade.in'), '200ms: tooltip still faded in') - start() + done() }, 200) }, 0) $tooltip.trigger('mouseenter') }) - test('should not show tooltip if leave event occurs before delay expires', function () { - stop() + test('should not show tooltip if leave event occurs before delay expires', function (assert) { + var done = assert.async() var $tooltip = $('') .appendTo('#qunit-fixture') @@ -845,14 +845,14 @@ $(function () { setTimeout(function () { ok(!$('.tooltip').is('.fade.in'), '200ms: tooltip not faded in') - start() + done() }, 200) $tooltip.trigger('mouseenter') }) - test('should not show tooltip if leave event occurs before delay expires, even if hide delay is 0', function () { - stop() + test('should not show tooltip if leave event occurs before delay expires, even if hide delay is 0', function (assert) { + var done = assert.async() var $tooltip = $('') .appendTo('#qunit-fixture') @@ -865,14 +865,14 @@ $(function () { setTimeout(function () { ok(!$('.tooltip').is('.fade.in'), '250ms: tooltip not faded in') - start() + done() }, 250) $tooltip.trigger('mouseenter') }) - test('should wait 200ms before hiding the tooltip', function () { - stop() + test('should wait 200ms before hiding the tooltip', function (assert) { + var done = assert.async() var $tooltip = $('') .appendTo('#qunit-fixture') @@ -889,7 +889,7 @@ $(function () { setTimeout(function () { ok(!$tooltip.data('bs.tooltip').$tip.is('.in'), '200ms: tooltip removed') - start() + done() }, 200) }, 0) @@ -897,14 +897,14 @@ $(function () { $tooltip.trigger('mouseenter') }) - test('should correctly position tooltips on SVG elements', function () { + test('should correctly position tooltips on SVG elements', function (assert) { if (!window.SVGElement) { // Skip IE8 since it doesn't support SVG expect(0) return } - stop() + var done = assert.async() var styles = '