From 4febcb4b492c322c71bdef579cc4ad99ea86e150 Mon Sep 17 00:00:00 2001 From: Kevin Kirsche Date: Sun, 1 Mar 2015 09:33:48 -0500 Subject: [Fixes #15953] Implement assert.expect in each unit test [Fixes #15953] Implement `assert.expect` in each unit test --- js/tests/unit/tooltip.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'js/tests/unit/tooltip.js') diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index e5409189b..c2e2b937b 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -4,6 +4,7 @@ $(function () { QUnit.module('tooltip plugin') QUnit.test('should be defined on jquery object', function (assert) { + assert.expect(1) assert.ok($(document.body).tooltip, 'tooltip method is defined') }) @@ -19,10 +20,12 @@ $(function () { }) QUnit.test('should provide no conflict', function (assert) { + assert.expect(1) assert.strictEqual($.fn.tooltip, undefined, 'tooltip was set back to undefined (org value)') }) QUnit.test('should return jquery collection containing the element', function (assert) { + assert.expect(2) var $el = $('
') var $tooltip = $el.bootstrapTooltip() assert.ok($tooltip instanceof $, 'returns jquery collection') @@ -30,20 +33,24 @@ $(function () { }) QUnit.test('should expose default settings', function (assert) { + assert.expect(1) assert.ok($.fn.bootstrapTooltip.Constructor.DEFAULTS, 'defaults is defined') }) QUnit.test('should empty title attribute', function (assert) { + assert.expect(1) var $trigger = $('').bootstrapTooltip() assert.strictEqual($trigger.attr('title'), '', 'title attribute was emptied') }) QUnit.test('should add data attribute for referencing original title', function (assert) { + assert.expect(1) var $trigger = $('').bootstrapTooltip() assert.strictEqual($trigger.attr('data-original-title'), 'Another tooltip', 'original title preserved in data attribute') }) QUnit.test('should add aria-describedby to the trigger on show', function (assert) { + assert.expect(3) var $trigger = $('') .bootstrapTooltip() .appendTo('#qunit-fixture') @@ -57,6 +64,7 @@ $(function () { }) QUnit.test('should remove aria-describedby from trigger on hide', function (assert) { + assert.expect(2) var $trigger = $('') .bootstrapTooltip() .appendTo('#qunit-fixture') @@ -69,6 +77,7 @@ $(function () { }) QUnit.test('should assign a unique id tooltip element', function (assert) { + assert.expect(2) $('') .appendTo('#qunit-fixture') .bootstrapTooltip('show') @@ -80,6 +89,7 @@ $(function () { }) QUnit.test('should place tooltips relative to placement option', function (assert) { + assert.expect(2) var $tooltip = $('') .appendTo('#qunit-fixture') .bootstrapTooltip({ placement: 'bottom' }) @@ -92,6 +102,7 @@ $(function () { }) QUnit.test('should allow html entities', function (assert) { + assert.expect(2) var $tooltip = $('') .appendTo('#qunit-fixture') .bootstrapTooltip({ html: true }) @@ -104,6 +115,7 @@ $(function () { }) QUnit.test('should respect custom classes', function (assert) { + assert.expect(2) var $tooltip = $('') .appendTo('#qunit-fixture') .bootstrapTooltip({ template: '
' }) @@ -116,6 +128,7 @@ $(function () { }) QUnit.test('should fire show event', function (assert) { + assert.expect(1) var done = assert.async() $('
') @@ -127,6 +140,7 @@ $(function () { }) QUnit.test('should fire shown event', function (assert) { + assert.expect(1) var done = assert.async() $('
') @@ -139,6 +153,7 @@ $(function () { }) QUnit.test('should not fire shown event when show was prevented', function (assert) { + assert.expect(1) var done = assert.async() $('
') @@ -154,6 +169,7 @@ $(function () { }) QUnit.test('should fire hide event', function (assert) { + assert.expect(1) var done = assert.async() $('
') @@ -169,6 +185,7 @@ $(function () { }) QUnit.test('should fire hidden event', function (assert) { + assert.expect(1) var done = assert.async() $('
') @@ -184,6 +201,7 @@ $(function () { }) QUnit.test('should not fire hidden event when hide was prevented', function (assert) { + assert.expect(1) var done = assert.async() $('
') @@ -203,6 +221,7 @@ $(function () { }) QUnit.test('should destroy tooltip', function (assert) { + assert.expect(7) var $tooltip = $('
') .bootstrapTooltip() .on('click.foo', function () {}) @@ -221,6 +240,7 @@ $(function () { }) QUnit.test('should show tooltip with delegate selector on click', function (assert) { + assert.expect(2) var $div = $('
') .appendTo('#qunit-fixture') .bootstrapTooltip({ @@ -236,6 +256,7 @@ $(function () { }) QUnit.test('should show tooltip when toggle is called', function (assert) { + assert.expect(1) $('') .appendTo('#qunit-fixture') .bootstrapTooltip({ trigger: 'manual' }) @@ -245,6 +266,7 @@ $(function () { }) QUnit.test('should hide previously shown tooltip when toggle is called on tooltip', function (assert) { + assert.expect(1) $('@ResentedHook') .appendTo('#qunit-fixture') .bootstrapTooltip({ trigger: 'manual' }) @@ -255,6 +277,7 @@ $(function () { }) QUnit.test('should place tooltips inside body when container is body', function (assert) { + assert.expect(3) var $tooltip = $('
') .appendTo('#qunit-fixture') .bootstrapTooltip({ container: 'body' }) @@ -268,6 +291,7 @@ $(function () { }) QUnit.test('should add position class before positioning so that position-specific styles are taken into account', function (assert) { + assert.expect(1) var styles = '') var $container = $('
') .css({ @@ -383,6 +411,7 @@ $(function () { }) QUnit.test('should position tip on top if viewport has enough space and placement is "auto top"', function (assert) { + assert.expect(2) var styles = '