aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit/dropdown.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tests/unit/dropdown.js')
-rw-r--r--js/tests/unit/dropdown.js76
1 files changed, 38 insertions, 38 deletions
diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js
index 9a7fbcff2..346f29fde 100644
--- a/js/tests/unit/dropdown.js
+++ b/js/tests/unit/dropdown.js
@@ -1,13 +1,13 @@
$(function () {
'use strict';
- module('dropdowns plugin')
+ QUnit.module('dropdowns plugin')
- test('should be defined on jquery object', function () {
- ok($(document.body).dropdown, 'dropdown method is defined')
+ QUnit.test('should be defined on jquery object', function (assert) {
+ assert.ok($(document.body).dropdown, 'dropdown method is defined')
})
- module('dropdowns', {
+ QUnit.module('dropdowns', {
setup: function () {
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$.fn.bootstrapDropdown = $.fn.dropdown.noConflict()
@@ -18,18 +18,18 @@ $(function () {
}
})
- test('should provide no conflict', function () {
- strictEqual($.fn.dropdown, undefined, 'dropdown was set back to undefined (org value)')
+ QUnit.test('should provide no conflict', function (assert) {
+ assert.strictEqual($.fn.dropdown, undefined, 'dropdown was set back to undefined (org value)')
})
- test('should return jquery collection containing the element', function () {
+ QUnit.test('should return jquery collection containing the element', function (assert) {
var $el = $('<div/>')
var $dropdown = $el.bootstrapDropdown()
- ok($dropdown instanceof $, 'returns jquery collection')
- strictEqual($dropdown[0], $el[0], 'collection contains element')
+ assert.ok($dropdown instanceof $, 'returns jquery collection')
+ assert.strictEqual($dropdown[0], $el[0], 'collection contains element')
})
- test('should not open dropdown if target is disabled via attribute', function () {
+ QUnit.test('should not open dropdown if target is disabled via attribute', function (assert) {
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<button disabled href="#" class="btn dropdown-toggle" data-toggle="dropdown">Dropdown</button>'
@@ -43,10 +43,10 @@ $(function () {
+ '</ul>'
var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
- ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
+ assert.ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
})
- test('should not open dropdown if target is disabled via class', function () {
+ QUnit.test('should not open dropdown if target is disabled via class', function (assert) {
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<button href="#" class="btn dropdown-toggle disabled" data-toggle="dropdown">Dropdown</button>'
@@ -60,10 +60,10 @@ $(function () {
+ '</ul>'
var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
- ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
+ assert.ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
})
- test('should add class open to menu if clicked', function () {
+ QUnit.test('should add class open to menu if clicked', function (assert) {
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
@@ -77,10 +77,10 @@ $(function () {
+ '</ul>'
var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
- ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
+ assert.ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
})
- test('should test if element has a # before assuming it\'s a selector', function () {
+ QUnit.test('should test if element has a # before assuming it\'s a selector', function (assert) {
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="/foo/" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
@@ -94,11 +94,11 @@ $(function () {
+ '</ul>'
var $dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').bootstrapDropdown().click()
- ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
+ assert.ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
})
- test('should remove "open" class if body is clicked', function () {
+ QUnit.test('should remove "open" class if body is clicked', function (assert) {
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
@@ -116,12 +116,12 @@ $(function () {
.bootstrapDropdown()
.click()
- ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
+ assert.ok($dropdown.parent('.dropdown').hasClass('open'), '"open" class added on click')
$(document.body).click()
- ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class removed')
+ assert.ok(!$dropdown.parent('.dropdown').hasClass('open'), '"open" class removed')
})
- test('should remove "open" class if body is clicked, with multiple dropdowns', function () {
+ QUnit.test('should remove "open" class if body is clicked, with multiple dropdowns', function (assert) {
var dropdownHTML = '<ul class="nav">'
+ '<li><a href="#menu1">Menu 1</a></li>'
+ '<li class="dropdown" id="testmenu">'
@@ -142,22 +142,22 @@ $(function () {
var $first = $dropdowns.first()
var $last = $dropdowns.last()
- strictEqual($dropdowns.length, 2, 'two dropdowns')
+ assert.strictEqual($dropdowns.length, 2, 'two dropdowns')
$first.click()
- strictEqual($first.parents('.open').length, 1, '"open" class added on click')
- strictEqual($('#qunit-fixture .open').length, 1, 'only one dropdown is open')
+ assert.strictEqual($first.parents('.open').length, 1, '"open" class added on click')
+ assert.strictEqual($('#qunit-fixture .open').length, 1, 'only one dropdown is open')
$(document.body).click()
- strictEqual($('#qunit-fixture .open').length, 0, '"open" class removed')
+ assert.strictEqual($('#qunit-fixture .open').length, 0, '"open" class removed')
$last.click()
- strictEqual($last.parent('.open').length, 1, '"open" class added on click')
- strictEqual($('#qunit-fixture .open').length, 1, 'only one dropdown is open')
+ assert.strictEqual($last.parent('.open').length, 1, '"open" class added on click')
+ assert.strictEqual($('#qunit-fixture .open').length, 1, 'only one dropdown is open')
$(document.body).click()
- strictEqual($('#qunit-fixture .open').length, 0, '"open" class removed')
+ assert.strictEqual($('#qunit-fixture .open').length, 0, '"open" class removed')
})
- test('should fire show and hide event', function (assert) {
+ QUnit.test('should fire show and hide event', function (assert) {
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
@@ -179,10 +179,10 @@ $(function () {
$dropdown
.parent('.dropdown')
.on('show.bs.dropdown', function () {
- ok(true, 'show was fired')
+ assert.ok(true, 'show was fired')
})
.on('hide.bs.dropdown', function () {
- ok(true, 'hide was fired')
+ assert.ok(true, 'hide was fired')
done()
})
@@ -191,7 +191,7 @@ $(function () {
})
- test('should fire shown and hidden event', function (assert) {
+ QUnit.test('should fire shown and hidden event', function (assert) {
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
@@ -213,10 +213,10 @@ $(function () {
$dropdown
.parent('.dropdown')
.on('shown.bs.dropdown', function () {
- ok(true, 'shown was fired')
+ assert.ok(true, 'shown was fired')
})
.on('hidden.bs.dropdown', function () {
- ok(true, 'hidden was fired')
+ assert.ok(true, 'hidden was fired')
done()
})
@@ -224,7 +224,7 @@ $(function () {
$(document.body).click()
})
- test('should ignore keyboard events within <input>s and <textarea>s', function (assert) {
+ QUnit.test('should ignore keyboard events within <input>s and <textarea>s', function (assert) {
var done = assert.async()
var dropdownHTML = '<ul class="tabs">'
@@ -251,13 +251,13 @@ $(function () {
$dropdown
.parent('.dropdown')
.on('shown.bs.dropdown', function () {
- ok(true, 'shown was fired')
+ assert.ok(true, 'shown was fired')
$input.focus().trigger($.Event('keydown', { which: 38 }))
- ok($(document.activeElement).is($input), 'input still focused')
+ assert.ok($(document.activeElement).is($input), 'input still focused')
$textarea.focus().trigger($.Event('keydown', { which: 38 }))
- ok($(document.activeElement).is($textarea), 'textarea still focused')
+ assert.ok($(document.activeElement).is($textarea), 'textarea still focused')
done()
})