Commit 420a8088 authored by Heinrich Fenkart's avatar Heinrich Fenkart
Browse files

Merge pull request #15961 from kkirsche/ImplementAssertExpect

[Fixes #15953] Implement assert.expect in each unit test
parents ddd09f6f 4febcb4b
Showing with 198 additions and 4 deletions
+198 -4
......@@ -14,6 +14,8 @@
<script>
// See https://github.com/axemclion/grunt-saucelabs#test-result-details-with-qunit
var log = []
// Require assert.expect in each test.
QUnit.config.requireExpects = true
QUnit.done(function (testResults) {
var tests = []
for (var i = 0, len = log.length; i < len; i++) {
......
......@@ -4,6 +4,7 @@ $(function () {
QUnit.module('affix plugin')
QUnit.test('should be defined on jquery object', function (assert) {
assert.expect(1)
assert.ok($(document.body).affix, 'affix method is defined')
})
......@@ -19,10 +20,12 @@ $(function () {
})
QUnit.test('should provide no conflict', function (assert) {
assert.expect(1)
assert.strictEqual($.fn.affix, undefined, 'affix was set back to undefined (org value)')
})
QUnit.test('should return jquery collection containing the element', function (assert) {
assert.expect(2)
var $el = $('<div/>')
var $affix = $el.bootstrapAffix()
assert.ok($affix instanceof $, 'returns jquery collection')
......@@ -30,12 +33,14 @@ $(function () {
})
QUnit.test('should exit early if element is not visible', function (assert) {
assert.expect(1)
var $affix = $('<div style="display: none"/>').bootstrapAffix()
$affix.data('bs.affix').checkPosition()
assert.ok(!$affix.hasClass('affix'), 'affix class was not added')
})
QUnit.test('should trigger affixed event after affix', function (assert) {
assert.expect(2)
var done = assert.async()
var templateHTML = '<div id="affixTarget">'
......@@ -70,6 +75,7 @@ $(function () {
})
QUnit.test('should affix-top when scrolling up to offset when parent has padding', function (assert) {
assert.expect(1)
var done = assert.async()
var templateHTML = '<div id="padding-offset" style="padding-top: 20px;">'
......
......@@ -4,6 +4,7 @@ $(function () {
QUnit.module('alert plugin')
QUnit.test('should be defined on jquery object', function (assert) {
assert.expect(1)
assert.ok($(document.body).alert, 'alert method is defined')
})
......@@ -19,10 +20,12 @@ $(function () {
})
QUnit.test('should provide no conflict', function (assert) {
assert.expect(1)
assert.strictEqual($.fn.alert, undefined, 'alert was set back to undefined (org value)')
})
QUnit.test('should return jquery collection containing the element', function (assert) {
assert.expect(2)
var $el = $('<div/>')
var $alert = $el.bootstrapAlert()
assert.ok($alert instanceof $, 'returns jquery collection')
......@@ -30,6 +33,7 @@ $(function () {
})
QUnit.test('should fade element out on clicking .close', function (assert) {
assert.expect(1)
var alertHTML = '<div class="alert alert-danger fade in">'
+ '<a class="close" href="#" data-dismiss="alert">×</a>'
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
......@@ -42,6 +46,7 @@ $(function () {
})
QUnit.test('should remove element when clicking .close', function (assert) {
assert.expect(2)
var alertHTML = '<div class="alert alert-danger fade in">'
+ '<a class="close" href="#" data-dismiss="alert">×</a>'
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
......@@ -56,6 +61,7 @@ $(function () {
})
QUnit.test('should not fire closed when close is prevented', function (assert) {
assert.expect(1)
var done = assert.async()
$('<div class="alert"/>')
.on('close.bs.alert', function (e) {
......
......@@ -4,6 +4,7 @@ $(function () {
QUnit.module('button plugin')
QUnit.test('should be defined on jquery object', function (assert) {
assert.expect(1)
assert.ok($(document.body).button, 'button method is defined')
})
......@@ -19,10 +20,12 @@ $(function () {
})
QUnit.test('should provide no conflict', function (assert) {
assert.expect(1)
assert.strictEqual($.fn.button, undefined, 'button was set back to undefined (org value)')
})
QUnit.test('should return jquery collection containing the element', function (assert) {
assert.expect(2)
var $el = $('<div/>')
var $button = $el.bootstrapButton()
assert.ok($button instanceof $, 'returns jquery collection')
......@@ -30,6 +33,7 @@ $(function () {
})
QUnit.test('should return set state to loading', function (assert) {
assert.expect(4)
var $btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
assert.strictEqual($btn.html(), 'mdo', 'btn text equals mdo')
$btn.bootstrapButton('loading')
......@@ -43,6 +47,7 @@ $(function () {
})
QUnit.test('should return reset state', function (assert) {
assert.expect(7)
var $btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
assert.strictEqual($btn.html(), 'mdo', 'btn text equals mdo')
$btn.bootstrapButton('loading')
......@@ -64,6 +69,7 @@ $(function () {
})
QUnit.test('should work with an empty string as reset state', function (assert) {
assert.expect(7)
var $btn = $('<button class="btn" data-loading-text="fat"/>')
assert.strictEqual($btn.html(), '', 'btn text equals ""')
$btn.bootstrapButton('loading')
......@@ -85,6 +91,7 @@ $(function () {
})
QUnit.test('should toggle active', function (assert) {
assert.expect(2)
var $btn = $('<button class="btn" data-toggle="button">mdo</button>')
assert.ok(!$btn.hasClass('active'), 'btn does not have active class')
$btn.bootstrapButton('toggle')
......@@ -92,6 +99,7 @@ $(function () {
})
QUnit.test('should toggle active when btn children are clicked', function (assert) {
assert.expect(2)
var $btn = $('<button class="btn" data-toggle="button">mdo</button>')
var $inner = $('<i/>')
$btn
......@@ -103,6 +111,7 @@ $(function () {
})
QUnit.test('should toggle aria-pressed', function (assert) {
assert.expect(2)
var $btn = $('<button class="btn" data-toggle="button" aria-pressed="false">redux</button>')
assert.strictEqual($btn.attr('aria-pressed'), 'false', 'btn aria-pressed state is false')
$btn.bootstrapButton('toggle')
......@@ -110,6 +119,7 @@ $(function () {
})
QUnit.test('should toggle aria-pressed when btn children are clicked', function (assert) {
assert.expect(2)
var $btn = $('<button class="btn" data-toggle="button" aria-pressed="false">redux</button>')
var $inner = $('<i/>')
$btn
......@@ -121,6 +131,7 @@ $(function () {
})
QUnit.test('should toggle active when btn children are clicked within btn-group', function (assert) {
assert.expect(2)
var $btngroup = $('<div class="btn-group" data-toggle="buttons"/>')
var $btn = $('<button class="btn">fat</button>')
var $inner = $('<i/>')
......@@ -133,6 +144,7 @@ $(function () {
})
QUnit.test('should check for closest matching toggle', function (assert) {
assert.expect(12)
var groupHTML = '<div class="btn-group" data-toggle="buttons">'
+ '<label class="btn btn-primary active">'
+ '<input type="radio" name="options" id="option1" checked="true"> Option 1'
......
......@@ -4,6 +4,7 @@ $(function () {
QUnit.module('carousel plugin')
QUnit.test('should be defined on jQuery object', function (assert) {
assert.expect(1)
assert.ok($(document.body).carousel, 'carousel method is defined')
})
......@@ -19,10 +20,12 @@ $(function () {
})
QUnit.test('should provide no conflict', function (assert) {
assert.expect(1)
assert.strictEqual($.fn.carousel, undefined, 'carousel was set back to undefined (orig value)')
})
QUnit.test('should return jquery collection containing the element', function (assert) {
assert.expect(2)
var $el = $('<div/>')
var $carousel = $el.bootstrapCarousel()
assert.ok($carousel instanceof $, 'returns jquery collection')
......@@ -30,6 +33,7 @@ $(function () {
})
QUnit.test('should not fire slid when slide is prevented', function (assert) {
assert.expect(1)
var done = assert.async()
$('<div class="carousel"/>')
.on('slide.bs.carousel', function (e) {
......@@ -44,6 +48,7 @@ $(function () {
})
QUnit.test('should reset when slide is prevented', function (assert) {
assert.expect(6)
var carouselHTML = '<div id="carousel-example-generic" class="carousel slide">'
+ '<ol class="carousel-indicators">'
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>'
......@@ -89,6 +94,7 @@ $(function () {
})
QUnit.test('should fire slide event with direction', function (assert) {
assert.expect(4)
var carouselHTML = '<div id="myCarousel" class="carousel slide">'
+ '<div class="carousel-inner">'
+ '<div class="item active">'
......@@ -143,6 +149,7 @@ $(function () {
})
QUnit.test('should fire slid event with direction', function (assert) {
assert.expect(4)
var carouselHTML = '<div id="myCarousel" class="carousel slide">'
+ '<div class="carousel-inner">'
+ '<div class="item active">'
......@@ -197,6 +204,7 @@ $(function () {
})
QUnit.test('should fire slide event with relatedTarget', function (assert) {
assert.expect(2)
var template = '<div id="myCarousel" class="carousel slide">'
+ '<div class="carousel-inner">'
+ '<div class="item active">'
......@@ -243,6 +251,7 @@ $(function () {
})
QUnit.test('should fire slid event with relatedTarget', function (assert) {
assert.expect(2)
var template = '<div id="myCarousel" class="carousel slide">'
+ '<div class="carousel-inner">'
+ '<div class="item active">'
......@@ -289,6 +298,7 @@ $(function () {
})
QUnit.test('should set interval from data attribute', function (assert) {
assert.expect(4)
var templateHTML = '<div id="myCarousel" class="carousel slide">'
+ '<div class="carousel-inner">'
+ '<div class="item active">'
......@@ -350,6 +360,7 @@ $(function () {
})
QUnit.test('should skip over non-items when using item indices', function (assert) {
assert.expect(2)
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="1814">'
+ '<div class="carousel-inner">'
+ '<div class="item active">'
......@@ -375,6 +386,7 @@ $(function () {
})
QUnit.test('should skip over non-items when using next/prev methods', function (assert) {
assert.expect(2)
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="1814">'
+ '<div class="carousel-inner">'
+ '<div class="item active">'
......@@ -400,6 +412,7 @@ $(function () {
})
QUnit.test('should go to previous item if left arrow key is pressed', function (assert) {
assert.expect(2)
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">'
+ '<div class="carousel-inner">'
+ '<div id="first" class="item">'
......@@ -425,6 +438,7 @@ $(function () {
})
QUnit.test('should go to next item if right arrow key is pressed', function (assert) {
assert.expect(2)
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">'
+ '<div class="carousel-inner">'
+ '<div id="first" class="item active">'
......@@ -450,6 +464,7 @@ $(function () {
})
QUnit.test('should support disabling the keyboard navigation', function (assert) {
assert.expect(3)
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false" data-keyboard="false">'
+ '<div class="carousel-inner">'
+ '<div id="first" class="item active">'
......@@ -479,6 +494,7 @@ $(function () {
})
QUnit.test('should ignore keyboard events within <input>s and <textarea>s', function (assert) {
assert.expect(7)
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false">'
+ '<div class="carousel-inner">'
+ '<div id="first" class="item active">'
......@@ -521,6 +537,7 @@ $(function () {
})
QUnit.test('should only add mouseenter and mouseleave listeners when not on mobile', function (assert) {
assert.expect(2)
var isMobile = 'ontouchstart' in document.documentElement
var templateHTML = '<div id="myCarousel" class="carousel" data-interval="false" data-pause="hover">'
+ '<div class="carousel-inner">'
......@@ -543,6 +560,7 @@ $(function () {
})
QUnit.test('should wrap around from end to start when wrap option is true', function (assert) {
assert.expect(3)
var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="true">'
+ '<ol class="carousel-indicators">'
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>'
......@@ -587,6 +605,7 @@ $(function () {
})
QUnit.test('should wrap around from start to end when wrap option is true', function (assert) {
assert.expect(1)
var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="true">'
+ '<ol class="carousel-indicators">'
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>'
......@@ -620,6 +639,7 @@ $(function () {
})
QUnit.test('should stay at the end when the next method is called and wrap is false', function (assert) {
assert.expect(3)
var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="false">'
+ '<ol class="carousel-indicators">'
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>'
......@@ -665,6 +685,7 @@ $(function () {
})
QUnit.test('should stay at the start when the prev method is called and wrap is false', function (assert) {
assert.expect(1)
var carouselHTML = '<div id="carousel-example-generic" class="carousel slide" data-wrap="false">'
+ '<ol class="carousel-indicators">'
+ '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"/>'
......
......@@ -4,6 +4,7 @@ $(function () {
QUnit.module('collapse plugin')
QUnit.test('should be defined on jquery object', function (assert) {
assert.expect(1)
assert.ok($(document.body).collapse, 'collapse method is defined')
})
......@@ -19,10 +20,12 @@ $(function () {
})
QUnit.test('should provide no conflict', function (assert) {
assert.expect(1)
assert.strictEqual($.fn.collapse, undefined, 'collapse was set back to undefined (org value)')
})
QUnit.test('should return jquery collection containing the element', function (assert) {
assert.expect(2)
var $el = $('<div/>')
var $collapse = $el.bootstrapCollapse()
assert.ok($collapse instanceof $, 'returns jquery collection')
......@@ -30,6 +33,7 @@ $(function () {
})
QUnit.test('should show a collapsed element', function (assert) {
assert.expect(2)
var $el = $('<div class="collapse"/>').bootstrapCollapse('show')
assert.ok($el.hasClass('in'), 'has class "in"')
......@@ -37,6 +41,7 @@ $(function () {
})
QUnit.test('should hide a collapsed element', function (assert) {
assert.expect(2)
var $el = $('<div class="collapse"/>').bootstrapCollapse('hide')
assert.ok(!$el.hasClass('in'), 'does not have class "in"')
......@@ -44,6 +49,7 @@ $(function () {
})
QUnit.test('should not fire shown when show is prevented', function (assert) {
assert.expect(1)
var done = assert.async()
$('<div class="collapse"/>')
......@@ -59,6 +65,7 @@ $(function () {
})
QUnit.test('should reset style to auto after finishing opening collapse', function (assert) {
assert.expect(2)
var done = assert.async()
$('<div class="collapse" style="height: 0px"/>')
......@@ -73,6 +80,7 @@ $(function () {
})
QUnit.test('should remove "collapsed" class from target when collapse is shown', function (assert) {
assert.expect(1)
var done = assert.async()
var $target = $('<a data-toggle="collapse" class="collapsed" href="#test1"/>').appendTo('#qunit-fixture')
......@@ -88,6 +96,7 @@ $(function () {
})
QUnit.test('should add "collapsed" class to target when collapse is hidden', function (assert) {
assert.expect(1)
var done = assert.async()
var $target = $('<a data-toggle="collapse" href="#test1"/>').appendTo('#qunit-fixture')
......@@ -103,6 +112,7 @@ $(function () {
})
QUnit.test('should remove "collapsed" class from all triggers targeting the collapse when the collapse is shown', function (assert) {
assert.expect(2)
var done = assert.async()
var $target = $('<a data-toggle="collapse" class="collapsed" href="#test1"/>').appendTo('#qunit-fixture')
......@@ -120,6 +130,7 @@ $(function () {
})
QUnit.test('should add "collapsed" class to all triggers targeting the collapse when the collapse is hidden', function (assert) {
assert.expect(2)
var done = assert.async()
var $target = $('<a data-toggle="collapse" href="#test1"/>').appendTo('#qunit-fixture')
......@@ -137,9 +148,8 @@ $(function () {
})
QUnit.test('should not close a collapse when initialized with "show" if already shown', function (assert) {
var done = assert.async()
assert.expect(0)
var done = assert.async()
var $test = $('<div id="test1" class="in"/>')
.appendTo('#qunit-fixture')
......@@ -153,9 +163,8 @@ $(function () {
})
QUnit.test('should open a collapse when initialized with "show" if not already shown', function (assert) {
var done = assert.async()
assert.expect(1)
var done = assert.async()
var $test = $('<div id="test1" />')
.appendTo('#qunit-fixture')
......@@ -169,6 +178,7 @@ $(function () {
})
QUnit.test('should remove "collapsed" class from active accordion target', function (assert) {
assert.expect(3)
var done = assert.async()
var accordionHTML = '<div class="panel-group" id="accordion">'
......@@ -202,6 +212,7 @@ $(function () {
})
QUnit.test('should allow dots in data-parent', function (assert) {
assert.expect(3)
var done = assert.async()
var accordionHTML = '<div class="panel-group accordion">'
......@@ -235,6 +246,7 @@ $(function () {
})
QUnit.test('should set aria-expanded="true" on target when collapse is shown', function (assert) {
assert.expect(1)
var done = assert.async()
var $target = $('<a data-toggle="collapse" class="collapsed" href="#test1" aria-expanded="false"/>').appendTo('#qunit-fixture')
......@@ -250,6 +262,7 @@ $(function () {
})
QUnit.test('should set aria-expanded="false" on target when collapse is hidden', function (assert) {
assert.expect(1)
var done = assert.async()
var $target = $('<a data-toggle="collapse" href="#test1" aria-expanded="true"/>').appendTo('#qunit-fixture')
......@@ -265,6 +278,7 @@ $(function () {
})
QUnit.test('should set aria-expanded="true" on all triggers targeting the collapse when the collapse is shown', function (assert) {
assert.expect(2)
var done = assert.async()
var $target = $('<a data-toggle="collapse" class="collapsed" href="#test1" aria-expanded="false"/>').appendTo('#qunit-fixture')
......@@ -282,6 +296,7 @@ $(function () {
})
QUnit.test('should set aria-expanded="false" on all triggers targeting the collapse when the collapse is hidden', function (assert) {
assert.expect(2)
var done = assert.async()
var $target = $('<a data-toggle="collapse" href="#test1" aria-expanded="true"/>').appendTo('#qunit-fixture')
......@@ -299,6 +314,7 @@ $(function () {
})
QUnit.test('should change aria-expanded from active accordion target to "false" and set the newly active one to "true"', function (assert) {
assert.expect(3)
var done = assert.async()
var accordionHTML = '<div class="panel-group" id="accordion">'
......@@ -332,6 +348,7 @@ $(function () {
})
QUnit.test('should not fire show event if show is prevented because other element is still transitioning', function (assert) {
assert.expect(1)
var done = assert.async()
var accordionHTML = '<div id="accordion">'
......@@ -367,6 +384,7 @@ $(function () {
})
QUnit.test('should add "collapsed" class to target when collapse is hidden via manual invocation', function (assert) {
assert.expect(1)
var done = assert.async()
var $target = $('<a data-toggle="collapse" href="#test1"/>').appendTo('#qunit-fixture')
......@@ -381,6 +399,7 @@ $(function () {
})
QUnit.test('should remove "collapsed" class from target when collapse is shown via manual invocation', function (assert) {
assert.expect(1)
var done = assert.async()
var $target = $('<a data-toggle="collapse" class="collapsed" href="#test1"/>').appendTo('#qunit-fixture')
......
......@@ -4,6 +4,7 @@ $(function () {
QUnit.module('dropdowns plugin')
QUnit.test('should be defined on jquery object', function (assert) {
assert.expect(1)
assert.ok($(document.body).dropdown, 'dropdown method is defined')
})
......@@ -19,10 +20,12 @@ $(function () {
})
QUnit.test('should provide no conflict', function (assert) {
assert.expect(1)
assert.strictEqual($.fn.dropdown, undefined, 'dropdown was set back to undefined (org value)')
})
QUnit.test('should return jquery collection containing the element', function (assert) {
assert.expect(2)
var $el = $('<div/>')
var $dropdown = $el.bootstrapDropdown()
assert.ok($dropdown instanceof $, 'returns jquery collection')
......@@ -30,6 +33,7 @@ $(function () {
})
QUnit.test('should not open dropdown if target is disabled via attribute', function (assert) {
assert.expect(1)
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<button disabled href="#" class="btn dropdown-toggle" data-toggle="dropdown">Dropdown</button>'
......@@ -47,6 +51,7 @@ $(function () {
})
QUnit.test('should set aria-expanded="true" on target when dropdown menu is shown', function (assert) {
assert.expect(1)
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Dropdown</a>'
......@@ -67,6 +72,7 @@ $(function () {
})
QUnit.test('should set aria-expanded="false" on target when dropdown menu is hidden', function (assert) {
assert.expect(1)
var done = assert.async()
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
......@@ -96,6 +102,7 @@ $(function () {
})
QUnit.test('should not open dropdown if target is disabled via class', function (assert) {
assert.expect(1)
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<button href="#" class="btn dropdown-toggle disabled" data-toggle="dropdown">Dropdown</button>'
......@@ -113,6 +120,7 @@ $(function () {
})
QUnit.test('should add class open to menu if clicked', function (assert) {
assert.expect(1)
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
......@@ -130,6 +138,7 @@ $(function () {
})
QUnit.test('should test if element has a # before assuming it\'s a selector', function (assert) {
assert.expect(1)
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="/foo/" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
......@@ -148,6 +157,7 @@ $(function () {
QUnit.test('should remove "open" class if body is clicked', function (assert) {
assert.expect(2)
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
......@@ -171,6 +181,7 @@ $(function () {
})
QUnit.test('should remove "open" class if body is clicked, with multiple dropdowns', function (assert) {
assert.expect(7)
var dropdownHTML = '<ul class="nav">'
+ '<li><a href="#menu1">Menu 1</a></li>'
+ '<li class="dropdown" id="testmenu">'
......@@ -207,6 +218,7 @@ $(function () {
})
QUnit.test('should fire show and hide event', function (assert) {
assert.expect(2)
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
......@@ -241,6 +253,7 @@ $(function () {
QUnit.test('should fire shown and hidden event', function (assert) {
assert.expect(2)
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
......@@ -274,6 +287,7 @@ $(function () {
})
QUnit.test('should ignore keyboard events within <input>s and <textarea>s', function (assert) {
assert.expect(3)
var done = assert.async()
var dropdownHTML = '<ul class="tabs">'
......@@ -315,6 +329,7 @@ $(function () {
})
QUnit.test('should skip disabled element when using keyboard navigation', function (assert) {
assert.expect(1)
var dropdownHTML = '<ul class="tabs">'
+ '<li class="dropdown">'
+ '<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
......
......@@ -4,6 +4,7 @@ $(function () {
QUnit.module('modal plugin')
QUnit.test('should be defined on jquery object', function (assert) {
assert.expect(1)
assert.ok($(document.body).modal, 'modal method is defined')
})
......@@ -19,10 +20,12 @@ $(function () {
})
QUnit.test('should provide no conflict', function (assert) {
assert.expect(1)
assert.strictEqual($.fn.modal, undefined, 'modal was set back to undefined (orig value)')
})
QUnit.test('should return jquery collection containing the element', function (assert) {
assert.expect(2)
var $el = $('<div id="modal-test"/>')
var $modal = $el.bootstrapModal()
assert.ok($modal instanceof $, 'returns jquery collection')
......@@ -30,10 +33,12 @@ $(function () {
})
QUnit.test('should expose defaults var for settings', function (assert) {
assert.expect(1)
assert.ok($.fn.bootstrapModal.Constructor.DEFAULTS, 'default object exposed')
})
QUnit.test('should insert into dom when show method is called', function (assert) {
assert.expect(1)
var done = assert.async()
$('<div id="modal-test"/>')
......@@ -45,6 +50,7 @@ $(function () {
})
QUnit.test('should set aria-hidden to false when show method is called', function (assert) {
assert.expect(1)
var done = assert.async()
$('<div id="modal-test"/>')
......@@ -56,6 +62,7 @@ $(function () {
})
QUnit.test('should fire show event', function (assert) {
assert.expect(1)
var done = assert.async()
$('<div id="modal-test"/>')
......@@ -67,6 +74,7 @@ $(function () {
})
QUnit.test('should not fire shown when show was prevented', function (assert) {
assert.expect(1)
var done = assert.async()
$('<div id="modal-test"/>')
......@@ -82,6 +90,7 @@ $(function () {
})
QUnit.test('should hide modal when hide is called', function (assert) {
assert.expect(3)
var done = assert.async()
$('<div id="modal-test"/>')
......@@ -98,6 +107,7 @@ $(function () {
})
QUnit.test('should set aria-hidden to true when hide is called', function (assert) {
assert.expect(2)
var done = assert.async()
$('<div id="modal-test"/>')
......@@ -113,6 +123,7 @@ $(function () {
})
QUnit.test('should toggle when toggle is called', function (assert) {
assert.expect(3)
var done = assert.async()
$('<div id="modal-test"/>')
......@@ -129,6 +140,7 @@ $(function () {
})
QUnit.test('should remove from dom when click [data-dismiss="modal"]', function (assert) {
assert.expect(3)
var done = assert.async()
$('<div id="modal-test"><span class="close" data-dismiss="modal"/></div>')
......@@ -145,6 +157,7 @@ $(function () {
})
QUnit.test('should allow modal close with "backdrop:false"', function (assert) {
assert.expect(2)
var done = assert.async()
$('<div id="modal-test" data-backdrop="false"/>')
......@@ -160,6 +173,7 @@ $(function () {
})
QUnit.test('should close modal when clicking outside of modal-content', function (assert) {
assert.expect(3)
var done = assert.async()
$('<div id="modal-test"><div class="contents"/></div>')
......@@ -177,6 +191,7 @@ $(function () {
})
QUnit.test('should close modal when escape key is pressed via keydown', function (assert) {
assert.expect(3)
var done = assert.async()
var div = $('<div id="modal-test"/>')
......@@ -196,6 +211,7 @@ $(function () {
})
QUnit.test('should not close modal when escape key is pressed via keyup', function (assert) {
assert.expect(3)
var done = assert.async()
var div = $('<div id="modal-test"/>')
......@@ -215,6 +231,7 @@ $(function () {
})
QUnit.test('should trigger hide event once when clicking outside of modal-content', function (assert) {
assert.expect(1)
var done = assert.async()
var triggered
......@@ -233,6 +250,7 @@ $(function () {
})
QUnit.test('should close reopened modal with [data-dismiss="modal"] click', function (assert) {
assert.expect(2)
var done = assert.async()
$('<div id="modal-test"><div class="contents"><div id="close" data-dismiss="modal"/></div></div>')
......@@ -256,6 +274,7 @@ $(function () {
})
QUnit.test('should restore focus to toggling element when modal is hidden after having been opened via data-api', function (assert) {
assert.expect(1)
var done = assert.async()
var $toggleBtn = $('<button data-toggle="modal" data-target="#modal-test"/>').appendTo('#qunit-fixture')
......@@ -276,6 +295,7 @@ $(function () {
})
QUnit.test('should not restore focus to toggling element if the associated show event gets prevented', function (assert) {
assert.expect(1)
var done = assert.async()
var $toggleBtn = $('<button data-toggle="modal" data-target="#modal-test"/>').appendTo('#qunit-fixture')
var $otherBtn = $('<button id="other-btn"/>').appendTo('#qunit-fixture')
......@@ -303,6 +323,7 @@ $(function () {
})
QUnit.test('should restore inline body padding after closing', function (assert) {
assert.expect(2)
var done = assert.async()
var originalBodyPad = 0
var $body = $(document.body)
......@@ -324,6 +345,7 @@ $(function () {
})
QUnit.test('should ignore values set via CSS when trying to restore body padding after closing', function (assert) {
assert.expect(1)
var done = assert.async()
var $body = $(document.body)
var $style = $('<style>body { padding-right: 42px; }</style>').appendTo('head')
......@@ -341,6 +363,7 @@ $(function () {
})
QUnit.test('should ignore other inline styles when trying to restore body padding after closing', function (assert) {
assert.expect(2)
var done = assert.async()
var $body = $(document.body)
var $style = $('<style>body { padding-right: 42px; }</style>').appendTo('head')
......@@ -362,6 +385,7 @@ $(function () {
})
QUnit.test('should properly restore non-pixel inline body padding after closing', function (assert) {
assert.expect(1)
var done = assert.async()
var $body = $(document.body)
......
......@@ -4,6 +4,7 @@ $(function () {
QUnit.module('popover plugin')
QUnit.test('should be defined on jquery object', function (assert) {
assert.expect(1)
assert.ok($(document.body).popover, 'popover method is defined')
})
......@@ -19,10 +20,12 @@ $(function () {
})
QUnit.test('should provide no conflict', function (assert) {
assert.expect(1)
assert.strictEqual($.fn.popover, undefined, 'popover was set back to undefined (org value)')
})
QUnit.test('should return jquery collection containing the element', function (assert) {
assert.expect(2)
var $el = $('<div/>')
var $popover = $el.bootstrapPopover()
assert.ok($popover instanceof $, 'returns jquery collection')
......@@ -30,6 +33,7 @@ $(function () {
})
QUnit.test('should render popover element', function (assert) {
assert.expect(2)
var $popover = $('<a href="#" title="mdo" data-content="https://twitter.com/mdo">@mdo</a>')
.appendTo('#qunit-fixture')
.bootstrapPopover('show')
......@@ -40,12 +44,14 @@ $(function () {
})
QUnit.test('should store popover instance in popover data object', function (assert) {
assert.expect(1)
var $popover = $('<a href="#" title="mdo" data-content="https://twitter.com/mdo">@mdo</a>').bootstrapPopover()
assert.ok($popover.data('bs.popover'), 'popover instance exists')
})
QUnit.test('should store popover trigger in popover instance data object', function (assert) {
assert.expect(1)
var $popover = $('<a href="#" title="ResentedHook">@ResentedHook</a>')
.appendTo('#qunit-fixture')
.bootstrapPopover()
......@@ -56,6 +62,7 @@ $(function () {
})
QUnit.test('should get title and content from options', function (assert) {
assert.expect(4)
var $popover = $('<a href="#">@fat</a>')
.appendTo('#qunit-fixture')
.bootstrapPopover({
......@@ -78,6 +85,7 @@ $(function () {
})
QUnit.test('should not duplicate HTML object', function (assert) {
assert.expect(6)
var $div = $('<div/>').html('loves writing tests (╯°□°)╯︵ ┻━┻')
var $popover = $('<a href="#">@fat</a>')
......@@ -104,6 +112,7 @@ $(function () {
})
QUnit.test('should get title and content from attributes', function (assert) {
assert.expect(4)
var $popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
.appendTo('#qunit-fixture')
.bootstrapPopover()
......@@ -119,6 +128,7 @@ $(function () {
QUnit.test('should get title and content from attributes ignoring options passed via js', function (assert) {
assert.expect(4)
var $popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
.appendTo('#qunit-fixture')
.bootstrapPopover({
......@@ -136,6 +146,7 @@ $(function () {
})
QUnit.test('should respect custom template', function (assert) {
assert.expect(3)
var $popover = $('<a href="#">@fat</a>')
.appendTo('#qunit-fixture')
.bootstrapPopover({
......@@ -154,6 +165,7 @@ $(function () {
})
QUnit.test('should destroy popover', function (assert) {
assert.expect(7)
var $popover = $('<div/>')
.bootstrapPopover({
trigger: 'hover'
......@@ -174,6 +186,7 @@ $(function () {
})
QUnit.test('should render popover element using delegated selector', function (assert) {
assert.expect(2)
var $div = $('<div><a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a></div>')
.appendTo('#qunit-fixture')
.bootstrapPopover({
......@@ -189,6 +202,7 @@ $(function () {
})
QUnit.test('should detach popover content rather than removing it so that event handlers are left intact', function (assert) {
assert.expect(1)
var $content = $('<div class="content-with-handler"><a class="btn btn-warning">Button with event handler</a></div>').appendTo('#qunit-fixture')
var handlerCalled = false
......@@ -227,6 +241,7 @@ $(function () {
})
QUnit.test('should throw an error when initializing popover on the document object without specifying a delegation selector', function (assert) {
assert.expect(1)
assert.throws(function () {
$(document).bootstrapPopover({ title: 'What am I on?', content: 'My selector is missing' })
}, new Error('`selector` option must be specified when initializing popover on the window.document object!'))
......
......@@ -4,6 +4,7 @@ $(function () {
QUnit.module('scrollspy plugin')
QUnit.test('should be defined on jquery object', function (assert) {
assert.expect(1)
assert.ok($(document.body).scrollspy, 'scrollspy method is defined')
})
......@@ -19,10 +20,12 @@ $(function () {
})
QUnit.test('should provide no conflict', function (assert) {
assert.expect(1)
assert.strictEqual($.fn.scrollspy, undefined, 'scrollspy was set back to undefined (org value)')
})
QUnit.test('should return jquery collection containing the element', function (assert) {
assert.expect(2)
var $el = $('<div/>')
var $scrollspy = $el.bootstrapScrollspy()
assert.ok($scrollspy instanceof $, 'returns jquery collection')
......@@ -30,6 +33,7 @@ $(function () {
})
QUnit.test('should only switch "active" class on current target', function (assert) {
assert.expect(1)
var done = assert.async()
var sectionHTML = '<div id="root" class="active">'
......@@ -74,6 +78,7 @@ $(function () {
})
QUnit.test('should correctly select middle navigation option when large offset is used', function (assert) {
assert.expect(3)
var done = assert.async()
var sectionHTML = '<div id="header" style="height: 500px;"></div>'
......@@ -107,6 +112,7 @@ $(function () {
})
QUnit.test('should add the active class to the correct element', function (assert) {
assert.expect(2)
var navbarHtml =
'<nav class="navbar">'
+ '<ul class="nav">'
......@@ -143,6 +149,7 @@ $(function () {
})
QUnit.test('should add the active class correctly when there are nested elements at 0 scroll offset', function (assert) {
assert.expect(6)
var times = 0
var done = assert.async()
var navbarHtml = '<nav id="navigation" class="navbar">'
......@@ -181,6 +188,7 @@ $(function () {
})
QUnit.test('should clear selection if above the first section', function (assert) {
assert.expect(3)
var done = assert.async()
var sectionHTML = '<div id="header" style="height: 500px;"></div>'
......
......@@ -4,6 +4,7 @@ $(function () {
QUnit.module('tabs plugin')
QUnit.test('should be defined on jquery object', function (assert) {
assert.expect(1)
assert.ok($(document.body).tab, 'tabs method is defined')
})
......@@ -19,10 +20,12 @@ $(function () {
})
QUnit.test('should provide no conflict', function (assert) {
assert.expect(1)
assert.strictEqual($.fn.tab, undefined, 'tab was set back to undefined (org value)')
})
QUnit.test('should return jquery collection containing the element', function (assert) {
assert.expect(2)
var $el = $('<div/>')
var $tab = $el.bootstrapTab()
assert.ok($tab instanceof $, 'returns jquery collection')
......@@ -30,6 +33,7 @@ $(function () {
})
QUnit.test('should activate element by tab id', function (assert) {
assert.expect(2)
var tabsHTML = '<ul class="tabs">'
+ '<li><a href="#home">Home</a></li>'
+ '<li><a href="#profile">Profile</a></li>'
......@@ -45,6 +49,7 @@ $(function () {
})
QUnit.test('should activate element by tab id', function (assert) {
assert.expect(2)
var pillsHTML = '<ul class="pills">'
+ '<li><a href="#home">Home</a></li>'
+ '<li><a href="#profile">Profile</a></li>'
......@@ -60,6 +65,7 @@ $(function () {
})
QUnit.test('should not fire shown when show is prevented', function (assert) {
assert.expect(1)
var done = assert.async()
$('<div class="tab"/>')
......@@ -75,6 +81,7 @@ $(function () {
})
QUnit.test('show and shown events should reference correct relatedTarget', function (assert) {
assert.expect(2)
var done = assert.async()
var dropHTML = '<ul class="drop">'
......@@ -102,6 +109,7 @@ $(function () {
})
QUnit.test('should fire hide and hidden events', function (assert) {
assert.expect(2)
var done = assert.async()
var tabsHTML = '<ul class="tabs">'
......@@ -132,6 +140,7 @@ $(function () {
})
QUnit.test('should not fire hidden when hide is prevented', function (assert) {
assert.expect(1)
var done = assert.async()
var tabsHTML = '<ul class="tabs">'
......@@ -156,6 +165,7 @@ $(function () {
})
QUnit.test('hide and hidden events contain correct relatedTarget', function (assert) {
assert.expect(2)
var done = assert.async()
var tabsHTML = '<ul class="tabs">'
......@@ -179,6 +189,7 @@ $(function () {
})
QUnit.test('selected tab should have aria-expanded', function (assert) {
assert.expect(8)
var tabsHTML = '<ul class="nav nav-tabs">'
+ '<li class="active"><a href="#home" toggle="tab" aria-expanded="true">Home</a></li>'
+ '<li><a href="#profile" toggle="tab" aria-expanded="false">Profile</a></li>'
......
......@@ -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 = $('<div/>')
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 = $('<a href="#" rel="tooltip" title="Another tooltip"/>').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 = $('<a href="#" rel="tooltip" title="Another tooltip"/>').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 = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.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 = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.bootstrapTooltip()
.appendTo('#qunit-fixture')
......@@ -69,6 +77,7 @@ $(function () {
})
QUnit.test('should assign a unique id tooltip element', function (assert) {
assert.expect(2)
$('<a href="#" rel="tooltip" title="Another tooltip"/>')
.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 = $('<a href="#" rel="tooltip" title="Another 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 = $('<a href="#" rel="tooltip" title="&lt;b&gt;@fat&lt;/b&gt;"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({ html: true })
......@@ -104,6 +115,7 @@ $(function () {
})
QUnit.test('should respect custom classes', function (assert) {
assert.expect(2)
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({ template: '<div class="tooltip some-class"><div class="tooltip-arrow"/><div class="tooltip-inner"/></div>' })
......@@ -116,6 +128,7 @@ $(function () {
})
QUnit.test('should fire show event', function (assert) {
assert.expect(1)
var done = assert.async()
$('<div title="tooltip title"/>')
......@@ -127,6 +140,7 @@ $(function () {
})
QUnit.test('should fire shown event', function (assert) {
assert.expect(1)
var done = assert.async()
$('<div title="tooltip title"></div>')
......@@ -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()
$('<div title="tooltip title"/>')
......@@ -154,6 +169,7 @@ $(function () {
})
QUnit.test('should fire hide event', function (assert) {
assert.expect(1)
var done = assert.async()
$('<div title="tooltip title"/>')
......@@ -169,6 +185,7 @@ $(function () {
})
QUnit.test('should fire hidden event', function (assert) {
assert.expect(1)
var done = assert.async()
$('<div title="tooltip title"/>')
......@@ -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()
$('<div title="tooltip title"/>')
......@@ -203,6 +221,7 @@ $(function () {
})
QUnit.test('should destroy tooltip', function (assert) {
assert.expect(7)
var $tooltip = $('<div/>')
.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 = $('<div><a href="#" rel="tooltip" title="Another tooltip"/></div>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({
......@@ -236,6 +256,7 @@ $(function () {
})
QUnit.test('should show tooltip when toggle is called', function (assert) {
assert.expect(1)
$('<a href="#" rel="tooltip" title="tooltip on toggle"/>')
.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)
$('<a href="#" rel="tooltip" title="tooltip on toggle">@ResentedHook</a>')
.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 = $('<a href="#" rel="tooltip" title="Another 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 = '<style>'
+ '.tooltip.right { white-space: nowrap; }'
+ '.tooltip.right .tooltip-inner { max-width: none; }'
......@@ -296,6 +320,7 @@ $(function () {
})
QUnit.test('should use title attribute for tooltip text', function (assert) {
assert.expect(2)
var $tooltip = $('<a href="#" rel="tooltip" title="Simple tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip()
......@@ -308,6 +333,7 @@ $(function () {
})
QUnit.test('should prefer title attribute over title option', function (assert) {
assert.expect(2)
var $tooltip = $('<a href="#" rel="tooltip" title="Simple tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({
......@@ -322,6 +348,7 @@ $(function () {
})
QUnit.test('should use title option', function (assert) {
assert.expect(2)
var $tooltip = $('<a href="#" rel="tooltip"/>')
.appendTo('#qunit-fixture')
.bootstrapTooltip({
......@@ -336,6 +363,7 @@ $(function () {
})
QUnit.test('should be placed dynamically with the dynamic placement option', function (assert) {
assert.expect(6)
var $style = $('<style> a[rel="tooltip"] { display: inline-block; position: absolute; } </style>')
var $container = $('<div/>')
.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 = '<style>'
+ 'body { padding-top: 100px; }'
+ '#section { height: 300px; border: 1px solid red; padding-top: 50px }'
......@@ -408,6 +437,7 @@ $(function () {
})
QUnit.test('should position tip on bottom if the tip\'s dimension exceeds the viewport area and placement is "auto top"', function (assert) {
assert.expect(2)
var styles = '<style>'
+ 'body { padding-top: 100px; }'
+ '#section { height: 300px; border: 1px solid red; }'
......@@ -433,6 +463,7 @@ $(function () {
})
QUnit.test('should display the tip on top whenever scrollable viewport has enough room if the given placement is "auto top"', function (assert) {
assert.expect(2)
var styles = '<style>'
+ '#scrollable-div { height: 200px; overflow: auto; }'
+ '.tooltip-item { margin: 200px 0 400px; width: 150px; }'
......@@ -459,6 +490,7 @@ $(function () {
})
QUnit.test('should display the tip on bottom whenever scrollable viewport doesn\'t have enough room if the given placement is "auto top"', function (assert) {
assert.expect(2)
var styles = '<style>'
+ '#scrollable-div { height: 200px; overflow: auto; }'
+ '.tooltip-item { padding: 200px 0 400px; width: 150px; }'
......@@ -485,6 +517,7 @@ $(function () {
})
QUnit.test('should display the tip on bottom whenever scrollable viewport has enough room if the given placement is "auto bottom"', function (assert) {
assert.expect(2)
var styles = '<style>'
+ '#scrollable-div { height: 200px; overflow: auto; }'
+ '.spacer { height: 400px; }'
......@@ -515,6 +548,7 @@ $(function () {
})
QUnit.test('should display the tip on top whenever scrollable viewport doesn\'t have enough room if the given placement is "auto bottom"', function (assert) {
assert.expect(2)
var styles = '<style>'
+ '#scrollable-div { height: 200px; overflow: auto; }'
+ '.tooltip-item { margin-top: 400px; width: 150px; }'
......@@ -541,6 +575,7 @@ $(function () {
})
QUnit.test('should adjust the tip\'s top position when up against the top of the viewport', function (assert) {
assert.expect(2)
var styles = '<style>'
+ '.tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; }'
+ 'a[rel="tooltip"] { position: fixed; }'
......@@ -568,6 +603,7 @@ $(function () {
})
QUnit.test('should adjust the tip\'s top position when up against the bottom of the viewport', function (assert) {
assert.expect(2)
var styles = '<style>'
+ '.tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; }'
+ 'a[rel="tooltip"] { position: fixed; }'
......@@ -597,6 +633,7 @@ $(function () {
})
QUnit.test('should adjust the tip\'s left position when up against the left of the viewport', function (assert) {
assert.expect(2)
var styles = '<style>'
+ '.tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; }'
+ 'a[rel="tooltip"] { position: fixed; }'
......@@ -625,6 +662,7 @@ $(function () {
})
QUnit.test('should adjust the tip\'s left position when up against the right of the viewport', function (assert) {
assert.expect(2)
var styles = '<style>'
+ '.tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; }'
+ 'a[rel="tooltip"] { position: fixed; }'
......@@ -654,6 +692,7 @@ $(function () {
})
QUnit.test('should adjust the tip when up against the right of an arbitrary viewport', function (assert) {
assert.expect(2)
var styles = '<style>'
+ '.tooltip, .tooltip .tooltip-inner { width: 200px; height: 200px; max-width: none; }'
+ '.container-viewport { position: absolute; top: 50px; left: 60px; width: 300px; height: 300px; }'
......@@ -681,6 +720,7 @@ $(function () {
})
QUnit.test('should not error when trying to show an auto-placed tooltip that has been removed from the dom', function (assert) {
assert.expect(1)
var passed = true
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
......@@ -700,6 +740,7 @@ $(function () {
})
QUnit.test('should place tooltip on top of element', function (assert) {
assert.expect(1)
var done = assert.async()
var containerHTML = '<div>'
......@@ -737,6 +778,7 @@ $(function () {
})
QUnit.test('should place tooltip inside viewport', function (assert) {
assert.expect(1)
var done = assert.async()
var $container = $('<div/>')
......@@ -768,6 +810,7 @@ $(function () {
})
QUnit.test('should show tooltip if leave event hasn\'t occurred before delay expires', function (assert) {
assert.expect(2)
var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
......@@ -787,6 +830,7 @@ $(function () {
})
QUnit.test('should not show tooltip if leave event occurs before delay expires', function (assert) {
assert.expect(2)
var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
......@@ -807,6 +851,7 @@ $(function () {
})
QUnit.test('should not hide tooltip if leave event occurs and enter event occurs within the hide delay', function (assert) {
assert.expect(3)
var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
......@@ -832,6 +877,7 @@ $(function () {
})
QUnit.test('should not show tooltip if leave event occurs before delay expires', function (assert) {
assert.expect(2)
var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
......@@ -852,6 +898,7 @@ $(function () {
})
QUnit.test('should not show tooltip if leave event occurs before delay expires, even if hide delay is 0', function (assert) {
assert.expect(2)
var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
......@@ -872,6 +919,7 @@ $(function () {
})
QUnit.test('should wait 200ms before hiding the tooltip', function (assert) {
assert.expect(3)
var done = assert.async()
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
......@@ -903,6 +951,7 @@ $(function () {
assert.expect(0)
return
}
assert.expect(2)
var done = assert.async()
......@@ -936,6 +985,7 @@ $(function () {
})
QUnit.test('should correctly determine auto placement based on container rather than parent', function (assert) {
assert.expect(2)
var done = assert.async()
var styles = '<style>'
......@@ -977,6 +1027,7 @@ $(function () {
})
QUnit.test('should not reload the tooltip on subsequent mouseenter events', function (assert) {
assert.expect(1)
var titleHtml = function () {
var uid = $.fn.bootstrapTooltip.Constructor.prototype.getUID('tooltip')
return '<p id="tt-content">' + uid + '</p><p>' + uid + '</p><p>' + uid + '</p>'
......@@ -1003,6 +1054,7 @@ $(function () {
})
QUnit.test('should not reload the tooltip if the mouse leaves and re-enters before hiding', function (assert) {
assert.expect(4)
var titleHtml = function () {
var uid = $.fn.bootstrapTooltip.Constructor.prototype.getUID('tooltip')
return '<p id="tt-content">' + uid + '</p><p>' + uid + '</p><p>' + uid + '</p>'
......@@ -1038,6 +1090,7 @@ $(function () {
})
QUnit.test('should position arrow correctly when tooltip is moved to not appear offscreen', function (assert) {
assert.expect(2)
var done = assert.async()
var styles = '<style>'
......@@ -1075,6 +1128,7 @@ $(function () {
assert.expect(0)
return
}
assert.expect(2)
var done = assert.async()
......@@ -1108,6 +1162,7 @@ $(function () {
})
QUnit.test('should throw an error when initializing tooltip on the document object without specifying a delegation selector', function (assert) {
assert.expect(1)
assert.throws(function () {
$(document).bootstrapTooltip({ title: 'What am I on?' })
}, new Error('`selector` option must be specified when initializing tooltip on the window.document object!'))
......
Supports Markdown
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