mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-28 21:44:41 +00:00
Updated to latest version of Bootstrap
This commit is contained in:
19
cssbuild/twitter-bootstrap/js/tests/unit/bootstrap-affix.js
vendored
Executable file
19
cssbuild/twitter-bootstrap/js/tests/unit/bootstrap-affix.js
vendored
Executable file
@@ -0,0 +1,19 @@
|
||||
$(function () {
|
||||
|
||||
module("bootstrap-affix")
|
||||
|
||||
test("should be defined on jquery object", function () {
|
||||
ok($(document.body).affix, 'affix method is defined')
|
||||
})
|
||||
|
||||
test("should return element", function () {
|
||||
ok($(document.body).affix()[0] == document.body, 'document.body returned')
|
||||
})
|
||||
|
||||
test("should exit early if element is not visible", function () {
|
||||
var $affix = $('<div style="display: none"></div>').affix()
|
||||
$affix.data('affix').checkPosition()
|
||||
ok(!$affix.hasClass('affix'), 'affix class was not added')
|
||||
})
|
||||
|
||||
})
|
||||
@@ -62,7 +62,7 @@ $(function () {
|
||||
ok(btn.hasClass('active'), 'btn has class active')
|
||||
})
|
||||
|
||||
test("should toggle active when btn children are clicked within btn-group", function () {
|
||||
test("should toggle active when btn children are clicked within btn-group", function () {
|
||||
var btngroup = $('<div class="btn-group" data-toggle="buttons-checkbox"></div>')
|
||||
, btn = $('<button class="btn">fat</button>')
|
||||
, inner = $('<i></i>')
|
||||
@@ -74,4 +74,23 @@ $(function () {
|
||||
ok(btn.hasClass('active'), 'btn has class active')
|
||||
})
|
||||
|
||||
test("should check for closest matching toggle", function () {
|
||||
var group = $("<div data-toggle='buttons-radio'></div>")
|
||||
, btn1 = $("<button class='btn active'></button>")
|
||||
, btn2 = $("<button class='btn'></button>")
|
||||
, wrap = $("<div></div>")
|
||||
|
||||
wrap.append(btn1, btn2)
|
||||
|
||||
group
|
||||
.append(wrap)
|
||||
.appendTo($('#qunit-fixture'))
|
||||
|
||||
ok(btn1.hasClass('active'), 'btn1 has active class')
|
||||
ok(!btn2.hasClass('active'), 'btn2 does not have active class')
|
||||
btn2.click()
|
||||
ok(!btn1.hasClass('active'), 'btn1 does not have active class')
|
||||
ok(btn2.hasClass('active'), 'btn2 has active class')
|
||||
})
|
||||
|
||||
})
|
||||
@@ -12,7 +12,7 @@ $(function () {
|
||||
|
||||
test("should not fire sliden when slide is prevented", function () {
|
||||
$.support.transition = false
|
||||
stop();
|
||||
stop()
|
||||
$('<div class="carousel"/>')
|
||||
.bind('slide', function (e) {
|
||||
e.preventDefault();
|
||||
@@ -25,4 +25,18 @@ $(function () {
|
||||
.carousel('next')
|
||||
})
|
||||
|
||||
test("should fire slide event with relatedTarget", function () {
|
||||
var template = '<div id="myCarousel" class="carousel slide"><div class="carousel-inner"><div class="item active"><img src="assets/img/bootstrap-mdo-sfmoma-01.jpg" alt=""><div class="carousel-caption"><h4>{{_i}}First Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div><div class="item"><img src="assets/img/bootstrap-mdo-sfmoma-02.jpg" alt=""><div class="carousel-caption"><h4>{{_i}}Second Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div><div class="item"><img src="assets/img/bootstrap-mdo-sfmoma-03.jpg" alt=""><div class="carousel-caption"><h4>{{_i}}Third Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div></div><a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a><a class="right carousel-control" href="#myCarousel" data-slide="next">›</a></div>'
|
||||
$.support.transition = false
|
||||
stop()
|
||||
$(template)
|
||||
.on('slide', function (e) {
|
||||
e.preventDefault();
|
||||
ok(e.relatedTarget);
|
||||
ok($(e.relatedTarget).hasClass('item'));
|
||||
start();
|
||||
})
|
||||
.carousel('next')
|
||||
})
|
||||
|
||||
})
|
||||
@@ -24,7 +24,7 @@ $(function () {
|
||||
|
||||
test("should not fire shown when show is prevented", function () {
|
||||
$.support.transition = false
|
||||
stop();
|
||||
stop()
|
||||
$('<div class="collapse"/>')
|
||||
.bind('show', function (e) {
|
||||
e.preventDefault();
|
||||
@@ -39,7 +39,7 @@ $(function () {
|
||||
|
||||
test("should reset style to auto after finishing opening collapse", function () {
|
||||
$.support.transition = false
|
||||
stop();
|
||||
stop()
|
||||
$('<div class="collapse" style="height: 0px"/>')
|
||||
.bind('show', function () {
|
||||
ok(this.style.height == '0px')
|
||||
@@ -51,4 +51,38 @@ $(function () {
|
||||
.collapse('show')
|
||||
})
|
||||
|
||||
test("should add active class to target when collapse shown", function () {
|
||||
$.support.transition = false
|
||||
stop()
|
||||
|
||||
var target = $('<a data-toggle="collapse" href="#test1"></a>')
|
||||
.appendTo($('#qunit-fixture'))
|
||||
|
||||
var collapsible = $('<div id="test1"></div>')
|
||||
.appendTo($('#qunit-fixture'))
|
||||
.on('show', function () {
|
||||
ok(!target.hasClass('collapsed'))
|
||||
start()
|
||||
})
|
||||
|
||||
target.click()
|
||||
})
|
||||
|
||||
test("should remove active class to target when collapse hidden", function () {
|
||||
$.support.transition = false
|
||||
stop()
|
||||
|
||||
var target = $('<a data-toggle="collapse" href="#test1"></a>')
|
||||
.appendTo($('#qunit-fixture'))
|
||||
|
||||
var collapsible = $('<div id="test1" class="in"></div>')
|
||||
.appendTo($('#qunit-fixture'))
|
||||
.on('hide', function () {
|
||||
ok(target.hasClass('collapsed'))
|
||||
start()
|
||||
})
|
||||
|
||||
target.click()
|
||||
})
|
||||
|
||||
})
|
||||
@@ -61,6 +61,24 @@ $(function () {
|
||||
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 () {
|
||||
var dropdownHTML = '<ul class="tabs">'
|
||||
+ '<li class="dropdown">'
|
||||
+ '<a href="/foo/" class="dropdown-toggle" data-toggle="dropdown">Dropdown</a>'
|
||||
+ '<ul class="dropdown-menu">'
|
||||
+ '<li><a href="#">Secondary link</a></li>'
|
||||
+ '<li><a href="#">Something else here</a></li>'
|
||||
+ '<li class="divider"></li>'
|
||||
+ '<li><a href="#">Another link</a></li>'
|
||||
+ '</ul>'
|
||||
+ '</li>'
|
||||
+ '</ul>'
|
||||
, dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').dropdown().click()
|
||||
|
||||
ok(dropdown.parent('.dropdown').hasClass('open'), 'open class added on click')
|
||||
})
|
||||
|
||||
|
||||
test("should remove open class if body clicked", function () {
|
||||
var dropdownHTML = '<ul class="tabs">'
|
||||
+ '<li class="dropdown">'
|
||||
|
||||
@@ -90,4 +90,18 @@ $(function () {
|
||||
ok(!$('.popover').length, 'popover was removed')
|
||||
$('#qunit-fixture').empty()
|
||||
})
|
||||
|
||||
test("should destroy popover", function () {
|
||||
var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function(){})
|
||||
ok(popover.data('popover'), 'popover has data')
|
||||
ok(popover.data('events').mouseover && popover.data('events').mouseout, 'popover has hover event')
|
||||
ok(popover.data('events').click[0].namespace == 'foo', 'popover has extra click.foo event')
|
||||
popover.popover('show')
|
||||
popover.popover('destroy')
|
||||
ok(!popover.hasClass('in'), 'popover is hidden')
|
||||
ok(!popover.data('popover'), 'popover does not have data')
|
||||
ok(popover.data('events').click[0].namespace == 'foo', 'popover still has click.foo')
|
||||
ok(!popover.data('events').mouseover && !popover.data('events').mouseout, 'popover does not have any events')
|
||||
})
|
||||
|
||||
})
|
||||
@@ -113,7 +113,7 @@ $(function () {
|
||||
}, 50)
|
||||
})
|
||||
|
||||
test("should show tooltip if leave event hasn't occured before delay expires", function () {
|
||||
test("should show tooltip if leave event hasn't occurred before delay expires", function () {
|
||||
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.tooltip({ delay: 150 })
|
||||
@@ -128,28 +128,17 @@ $(function () {
|
||||
}, 200)
|
||||
})
|
||||
|
||||
test("should detect if title string is html or text: foo", function () {
|
||||
ok(!$.fn.tooltip.Constructor.prototype.isHTML('foo'), 'correctly detected html')
|
||||
})
|
||||
|
||||
test("should detect if title string is html or text: &lt;foo&gt;", function () {
|
||||
ok(!$.fn.tooltip.Constructor.prototype.isHTML('<foo>'), 'correctly detected html')
|
||||
})
|
||||
|
||||
test("should detect if title string is html or text: <div>foo</div>", function () {
|
||||
ok($.fn.tooltip.Constructor.prototype.isHTML('<div>foo</div>'), 'correctly detected html')
|
||||
})
|
||||
|
||||
test("should detect if title string is html or text: asdfa<div>foo</div>asdfasdf", function () {
|
||||
ok($.fn.tooltip.Constructor.prototype.isHTML('asdfa<div>foo</div>asdfasdf'), 'correctly detected html')
|
||||
})
|
||||
|
||||
test("should detect if title string is html or text: document.createElement('div')", function () {
|
||||
ok($.fn.tooltip.Constructor.prototype.isHTML(document.createElement('div')), 'correctly detected html')
|
||||
})
|
||||
|
||||
test("should detect if title string is html or text: $('<div />)", function () {
|
||||
ok($.fn.tooltip.Constructor.prototype.isHTML($('<div></div>')), 'correctly detected html')
|
||||
test("should destroy tooltip", function () {
|
||||
var tooltip = $('<div/>').tooltip().on('click.foo', function(){})
|
||||
ok(tooltip.data('tooltip'), 'tooltip has data')
|
||||
ok(tooltip.data('events').mouseover && tooltip.data('events').mouseout, 'tooltip has hover event')
|
||||
ok(tooltip.data('events').click[0].namespace == 'foo', 'tooltip has extra click.foo event')
|
||||
tooltip.tooltip('show')
|
||||
tooltip.tooltip('destroy')
|
||||
ok(!tooltip.hasClass('in'), 'tooltip is hidden')
|
||||
ok(!tooltip.data('tooltip'), 'tooltip does not have data')
|
||||
ok(tooltip.data('events').click[0].namespace == 'foo', 'tooltip still has click.foo')
|
||||
ok(!tooltip.data('events').mouseover && !tooltip.data('events').mouseout, 'tooltip does not have any events')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@@ -52,6 +52,42 @@ $(function () {
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
|
||||
test("should accept data source via synchronous function", function () {
|
||||
var $input = $('<input />').typeahead({
|
||||
source: function () {
|
||||
return ['aa', 'ab', 'ac']
|
||||
}
|
||||
})
|
||||
, typeahead = $input.data('typeahead')
|
||||
|
||||
$input.val('a')
|
||||
typeahead.lookup()
|
||||
|
||||
ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
|
||||
equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
|
||||
equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
|
||||
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
|
||||
test("should accept data source via asynchronous function", function () {
|
||||
var $input = $('<input />').typeahead({
|
||||
source: function (query, process) {
|
||||
process(['aa', 'ab', 'ac'])
|
||||
}
|
||||
})
|
||||
, typeahead = $input.data('typeahead')
|
||||
|
||||
$input.val('a')
|
||||
typeahead.lookup()
|
||||
|
||||
ok(typeahead.$menu.is(":visible"), 'typeahead is visible')
|
||||
equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
|
||||
equals(typeahead.$menu.find('.active').length, 1, 'one item is active')
|
||||
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
|
||||
test("should not explode when regex chars are entered", function () {
|
||||
var $input = $('<input />').typeahead({
|
||||
source: ['aa', 'ab', 'ac', 'mdo*', 'fat+']
|
||||
@@ -145,4 +181,24 @@ $(function () {
|
||||
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
|
||||
test("should start querying when minLength is met", function () {
|
||||
var $input = $('<input />').typeahead({
|
||||
source: ['aaaa', 'aaab', 'aaac'],
|
||||
minLength: 3
|
||||
})
|
||||
, typeahead = $input.data('typeahead')
|
||||
|
||||
$input.val('aa')
|
||||
typeahead.lookup()
|
||||
|
||||
equals(typeahead.$menu.find('li').length, 0, 'has 0 items in menu')
|
||||
|
||||
$input.val('aaa')
|
||||
typeahead.lookup()
|
||||
|
||||
equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
|
||||
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user