Commit 895b0006 authored by XhmikosR's avatar XhmikosR

Re-indent test files.

parent accc95cc
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
"eqeqeq" : false, "eqeqeq" : false,
"eqnull" : true, "eqnull" : true,
"expr" : true, "expr" : true,
"indent" : 2,
"laxbreak" : true, "laxbreak" : true,
"quotmark" : "single", "quotmark" : "single",
"validthis": true "validthis": true
......
$(function () { $(function () {
module('affix') module('affix')
test('should provide no conflict', function () { test('should provide no conflict', function () {
var affix = $.fn.affix.noConflict() var affix = $.fn.affix.noConflict()
ok(!$.fn.affix, 'affix was set back to undefined (org value)') ok(!$.fn.affix, 'affix was set back to undefined (org value)')
$.fn.affix = affix $.fn.affix = affix
}) })
test('should be defined on jquery object', function () { test('should be defined on jquery object', function () {
ok($(document.body).affix, 'affix method is defined') ok($(document.body).affix, 'affix method is defined')
}) })
test('should return element', function () { test('should return element', function () {
ok($(document.body).affix()[0] == document.body, 'document.body returned') ok($(document.body).affix()[0] == document.body, 'document.body returned')
}) })
test('should exit early if element is not visible', function () { test('should exit early if element is not visible', function () {
var $affix = $('<div style="display: none"></div>').affix() var $affix = $('<div style="display: none"></div>').affix()
$affix.data('bs.affix').checkPosition() $affix.data('bs.affix').checkPosition()
ok(!$affix.hasClass('affix'), 'affix class was not added') ok(!$affix.hasClass('affix'), 'affix class was not added')
})
test('should trigger affixed event after affix', function () {
stop()
var template = $('<div id="affixTarget"><ul><li>Please affix</li><li>And unaffix</li></ul></div><div id="affixAfter" style="height: 20000px; display:block;"></div>')
template.appendTo('body')
var affixer = $('#affixTarget').affix({
offset: $('#affixTarget ul').position()
})
$('#affixTarget')
.on('affix.bs.affix', function (e) {
ok(true, 'affix event triggered')
}).on('affixed.bs.affix', function (e) {
ok(true,'affixed event triggered')
$('#affixTarget').remove()
$('#affixAfter').remove()
start()
}) })
test('should trigger affixed event after affix', function () { setTimeout(function () {
stop() window.scrollTo(0, document.body.scrollHeight)
setTimeout(function () { window.scroll(0,0) }, 0)
var template = $('<div id="affixTarget"><ul><li>Please affix</li><li>And unaffix</li></ul></div><div id="affixAfter" style="height: 20000px; display:block;"></div>') },0)
template.appendTo('body') })
var affixer = $('#affixTarget').affix({
offset: $('#affixTarget ul').position()
})
$('#affixTarget')
.on('affix.bs.affix', function (e) {
ok(true, 'affix event triggered')
}).on('affixed.bs.affix', function (e) {
ok(true,'affixed event triggered')
$('#affixTarget').remove()
$('#affixAfter').remove()
start()
})
setTimeout(function () {
window.scrollTo(0, document.body.scrollHeight)
setTimeout(function () { window.scroll(0,0) }, 0)
},0)
})
}) })
$(function () { $(function () {
module('alert') module('alert')
test('should provide no conflict', function () { test('should provide no conflict', function () {
var alert = $.fn.alert.noConflict() var alert = $.fn.alert.noConflict()
ok(!$.fn.alert, 'alert was set back to undefined (org value)') ok(!$.fn.alert, 'alert was set back to undefined (org value)')
$.fn.alert = alert $.fn.alert = alert
}) })
test('should be defined on jquery object', function () { test('should be defined on jquery object', function () {
ok($(document.body).alert, 'alert method is defined') ok($(document.body).alert, 'alert method is defined')
}) })
test('should return element', function () { test('should return element', function () {
ok($(document.body).alert()[0] == document.body, 'document.body returned') ok($(document.body).alert()[0] == document.body, 'document.body returned')
}) })
test('should fade element out on clicking .close', function () { test('should fade element out on clicking .close', function () {
var alertHTML = '<div class="alert-message warning fade in">' + var alertHTML = '<div class="alert-message warning fade in">' +
'<a class="close" href="#" data-dismiss="alert">×</a>' + '<a class="close" href="#" data-dismiss="alert">×</a>' +
'<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>' + '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>' +
'</div>', '</div>',
alert = $(alertHTML).alert() alert = $(alertHTML).alert()
alert.find('.close').click() alert.find('.close').click()
ok(!alert.hasClass('in'), 'remove .in class on .close click') ok(!alert.hasClass('in'), 'remove .in class on .close click')
}) })
test('should remove element when clicking .close', function () { test('should remove element when clicking .close', function () {
$.support.transition = false $.support.transition = false
var alertHTML = '<div class="alert-message warning fade in">' + var alertHTML = '<div class="alert-message warning fade in">' +
'<a class="close" href="#" data-dismiss="alert">×</a>' + '<a class="close" href="#" data-dismiss="alert">×</a>' +
'<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>' + '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>' +
'</div>', '</div>',
alert = $(alertHTML).appendTo('#qunit-fixture').alert() alert = $(alertHTML).appendTo('#qunit-fixture').alert()
ok($('#qunit-fixture').find('.alert-message').length, 'element added to dom') ok($('#qunit-fixture').find('.alert-message').length, 'element added to dom')
alert.find('.close').click() alert.find('.close').click()
ok(!$('#qunit-fixture').find('.alert-message').length, 'element removed from dom') ok(!$('#qunit-fixture').find('.alert-message').length, 'element removed from dom')
})
test('should not fire closed when close is prevented', function () {
$.support.transition = false
stop();
$('<div class="alert"/>')
.on('close.bs.alert', function (e) {
e.preventDefault();
ok(true);
start();
}) })
.on('closed.bs.alert', function () {
test('should not fire closed when close is prevented', function () { ok(false);
$.support.transition = false
stop();
$('<div class="alert"/>')
.on('close.bs.alert', function (e) {
e.preventDefault();
ok(true);
start();
})
.on('closed.bs.alert', function () {
ok(false);
})
.alert('close')
}) })
.alert('close')
})
}) })
$(function () { $(function () {
module('button') module('button')
test('should provide no conflict', function () { test('should provide no conflict', function () {
var button = $.fn.button.noConflict() var button = $.fn.button.noConflict()
ok(!$.fn.button, 'button was set back to undefined (org value)') ok(!$.fn.button, 'button was set back to undefined (org value)')
$.fn.button = button $.fn.button = button
}) })
test('should be defined on jquery object', function () { test('should be defined on jquery object', function () {
ok($(document.body).button, 'button method is defined') ok($(document.body).button, 'button method is defined')
}) })
test('should return element', function () { test('should return element', function () {
ok($(document.body).button()[0] == document.body, 'document.body returned') ok($(document.body).button()[0] == document.body, 'document.body returned')
}) })
test('should return set state to loading', function () { test('should return set state to loading', function () {
var btn = $('<button class="btn" data-loading-text="fat">mdo</button>') var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
equal(btn.html(), 'mdo', 'btn text equals mdo') equal(btn.html(), 'mdo', 'btn text equals mdo')
btn.button('loading') btn.button('loading')
equal(btn.html(), 'fat', 'btn text equals fat') equal(btn.html(), 'fat', 'btn text equals fat')
stop() stop()
setTimeout(function () { setTimeout(function () {
ok(btn.attr('disabled'), 'btn is disabled') ok(btn.attr('disabled'), 'btn is disabled')
ok(btn.hasClass('disabled'), 'btn has disabled class') ok(btn.hasClass('disabled'), 'btn has disabled class')
start() start()
}, 0) }, 0)
}) })
test('should return reset state', function () { test('should return reset state', function () {
var btn = $('<button class="btn" data-loading-text="fat">mdo</button>') var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
equal(btn.html(), 'mdo', 'btn text equals mdo') equal(btn.html(), 'mdo', 'btn text equals mdo')
btn.button('loading') btn.button('loading')
equal(btn.html(), 'fat', 'btn text equals fat') equal(btn.html(), 'fat', 'btn text equals fat')
stop() stop()
setTimeout(function () { setTimeout(function () {
ok(btn.attr('disabled'), 'btn is disabled') ok(btn.attr('disabled'), 'btn is disabled')
ok(btn.hasClass('disabled'), 'btn has disabled class') ok(btn.hasClass('disabled'), 'btn has disabled class')
start() start()
stop() stop()
btn.button('reset') btn.button('reset')
equal(btn.html(), 'mdo', 'btn text equals mdo') equal(btn.html(), 'mdo', 'btn text equals mdo')
setTimeout(function () { setTimeout(function () {
ok(!btn.attr('disabled'), 'btn is not disabled') ok(!btn.attr('disabled'), 'btn is not disabled')
ok(!btn.hasClass('disabled'), 'btn does not have disabled class') ok(!btn.hasClass('disabled'), 'btn does not have disabled class')
start() start()
}, 0) }, 0)
}, 0) }, 0)
}) })
test('should toggle active', function () { test('should toggle active', function () {
var btn = $('<button class="btn">mdo</button>') var btn = $('<button class="btn">mdo</button>')
ok(!btn.hasClass('active'), 'btn does not have active class') ok(!btn.hasClass('active'), 'btn does not have active class')
btn.button('toggle') btn.button('toggle')
ok(btn.hasClass('active'), 'btn has class active') ok(btn.hasClass('active'), 'btn has class active')
}) })
test('should toggle active when btn children are clicked', function () { test('should toggle active when btn children are clicked', function () {
var btn = $('<button class="btn" data-toggle="button">mdo</button>'), var btn = $('<button class="btn" data-toggle="button">mdo</button>'),
inner = $('<i></i>') inner = $('<i></i>')
btn btn
.append(inner) .append(inner)
.appendTo($('#qunit-fixture')) .appendTo($('#qunit-fixture'))
ok(!btn.hasClass('active'), 'btn does not have active class') ok(!btn.hasClass('active'), 'btn does not have active class')
inner.click() inner.click()
ok(btn.hasClass('active'), 'btn has class active') 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"></div>'), var btngroup = $('<div class="btn-group" data-toggle="buttons"></div>'),
btn = $('<button class="btn">fat</button>'), btn = $('<button class="btn">fat</button>'),
inner = $('<i></i>') inner = $('<i></i>')
btngroup btngroup
.append(btn.append(inner)) .append(btn.append(inner))
.appendTo($('#qunit-fixture')) .appendTo($('#qunit-fixture'))
ok(!btn.hasClass('active'), 'btn does not have active class') ok(!btn.hasClass('active'), 'btn does not have active class')
inner.click() inner.click()
ok(btn.hasClass('active'), 'btn has class active') ok(btn.hasClass('active'), 'btn has class active')
}) })
test('should check for closest matching toggle', function () { test('should check for closest matching toggle', function () {
var group = '<div class="btn-group" data-toggle="buttons">' + var group = '<div class="btn-group" data-toggle="buttons">' +
'<label class="btn btn-primary active">' + '<label class="btn btn-primary active">' +
'<input type="radio" name="options" id="option1" checked="true"> Option 1' + '<input type="radio" name="options" id="option1" checked="true"> Option 1' +
'</label>' + '</label>' +
'<label class="btn btn-primary">' + '<label class="btn btn-primary">' +
'<input type="radio" name="options" id="option2"> Option 2' + '<input type="radio" name="options" id="option2"> Option 2' +
'</label>' + '</label>' +
'<label class="btn btn-primary">' + '<label class="btn btn-primary">' +
'<input type="radio" name="options" id="option3"> Option 3' + '<input type="radio" name="options" id="option3"> Option 3' +
'</label>' + '</label>' +
'</div>' '</div>'
group = $(group) group = $(group)
var btn1 = $(group.children()[0]) var btn1 = $(group.children()[0])
var btn2 = $(group.children()[1]) var btn2 = $(group.children()[1])
var btn3 = $(group.children()[2]) var btn3 = $(group.children()[2])
group.appendTo($('#qunit-fixture')) group.appendTo($('#qunit-fixture'))
ok(btn1.hasClass('active'), 'btn1 has active class') ok(btn1.hasClass('active'), 'btn1 has active class')
ok(btn1.find('input').prop('checked'), 'btn1 is checked') ok(btn1.find('input').prop('checked'), 'btn1 is checked')
ok(!btn2.hasClass('active'), 'btn2 does not have active class') ok(!btn2.hasClass('active'), 'btn2 does not have active class')
ok(!btn2.find('input').prop('checked'), 'btn2 is not checked') ok(!btn2.find('input').prop('checked'), 'btn2 is not checked')
btn2.find('input').click() btn2.find('input').click()
ok(!btn1.hasClass('active'), 'btn1 does not have active class') ok(!btn1.hasClass('active'), 'btn1 does not have active class')
ok(!btn1.find('input').prop('checked'), 'btn1 is checked') ok(!btn1.find('input').prop('checked'), 'btn1 is checked')
ok(btn2.hasClass('active'), 'btn2 has active class') ok(btn2.hasClass('active'), 'btn2 has active class')
ok(btn2.find('input').prop('checked'), 'btn2 is checked') ok(btn2.find('input').prop('checked'), 'btn2 is checked')
btn2.find('input').click() /* clicking an already checked radio should not un-check it */ btn2.find('input').click() /* clicking an already checked radio should not un-check it */
ok(!btn1.hasClass('active'), 'btn1 does not have active class') ok(!btn1.hasClass('active'), 'btn1 does not have active class')
ok(!btn1.find('input').prop('checked'), 'btn1 is checked') ok(!btn1.find('input').prop('checked'), 'btn1 is checked')
ok(btn2.hasClass('active'), 'btn2 has active class') ok(btn2.hasClass('active'), 'btn2 has active class')
ok(btn2.find('input').prop('checked'), 'btn2 is checked') ok(btn2.find('input').prop('checked'), 'btn2 is checked')
}) })
}) })
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
$(function () { $(function () {
module('scrollspy') module('scrollspy')
test('should provide no conflict', function () { test('should provide no conflict', function () {
var scrollspy = $.fn.scrollspy.noConflict() var scrollspy = $.fn.scrollspy.noConflict()
ok(!$.fn.scrollspy, 'scrollspy was set back to undefined (org value)') ok(!$.fn.scrollspy, 'scrollspy was set back to undefined (org value)')
$.fn.scrollspy = scrollspy $.fn.scrollspy = scrollspy
}) })
test('should be defined on jquery object', function () { test('should be defined on jquery object', function () {
ok($(document.body).scrollspy, 'scrollspy method is defined') ok($(document.body).scrollspy, 'scrollspy method is defined')
}) })
test('should return element', function () { test('should return element', function () {
ok($(document.body).scrollspy()[0] == document.body, 'document.body returned') ok($(document.body).scrollspy()[0] == document.body, 'document.body returned')
}) })
test('should switch active class on scroll', function () { test('should switch active class on scroll', function () {
var sectionHTML = '<div id="masthead"></div>' var sectionHTML = '<div id="masthead"></div>',
$section = $(sectionHTML).append('#qunit-fixture'), $section = $(sectionHTML).append('#qunit-fixture'),
topbarHTML = '<div class="topbar">' + topbarHTML = '<div class="topbar">' +
'<div class="topbar-inner">' + '<div class="topbar-inner">' +
'<div class="container">' + '<div class="container">' +
'<h3><a href="#">Bootstrap</a></h3>' + '<h3><a href="#">Bootstrap</a></h3>' +
'<li><a href="#masthead">Overview</a></li>' + '<li><a href="#masthead">Overview</a></li>' +
'</ul>' + '</ul>' +
'</div>' + '</div>' +
'</div>' + '</div>' +
'</div>', '</div>',
$topbar = $(topbarHTML).scrollspy() $topbar = $(topbarHTML).scrollspy()
ok($topbar.find('.active', true)) ok($topbar.find('.active', true))
}) })
}) })
$(function () { $(function () {
module('tabs') module('tabs')
test('should provide no conflict', function () { test('should provide no conflict', function () {
var tab = $.fn.tab.noConflict() var tab = $.fn.tab.noConflict()
ok(!$.fn.tab, 'tab was set back to undefined (org value)') ok(!$.fn.tab, 'tab was set back to undefined (org value)')
$.fn.tab = tab $.fn.tab = tab
}) })
test('should be defined on jquery object', function () { test('should be defined on jquery object', function () {
ok($(document.body).tab, 'tabs method is defined') ok($(document.body).tab, 'tabs method is defined')
}) })
test('should return element', function () { test('should return element', function () {
ok($(document.body).tab()[0] == document.body, 'document.body returned') ok($(document.body).tab()[0] == document.body, 'document.body returned')
}) })
test('should activate element by tab id', function () { test('should activate element by tab id', function () {
var tabsHTML = '<ul class="tabs">' + var tabsHTML = '<ul class="tabs">' +
'<li><a href="#home">Home</a></li>' + '<li><a href="#home">Home</a></li>' +
'<li><a href="#profile">Profile</a></li>' + '<li><a href="#profile">Profile</a></li>' +
'</ul>' '</ul>'
$('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo('#qunit-fixture') $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo('#qunit-fixture')
$(tabsHTML).find('li:last a').tab('show') $(tabsHTML).find('li:last a').tab('show')
equal($('#qunit-fixture').find('.active').attr('id'), 'profile') equal($('#qunit-fixture').find('.active').attr('id'), 'profile')
$(tabsHTML).find('li:first a').tab('show') $(tabsHTML).find('li:first a').tab('show')
equal($('#qunit-fixture').find('.active').attr('id'), 'home') equal($('#qunit-fixture').find('.active').attr('id'), 'home')
}) })
test('should activate element by tab id', function () { test('should activate element by tab id', function () {
var pillsHTML = '<ul class="pills">' + var pillsHTML = '<ul class="pills">' +
'<li><a href="#home">Home</a></li>' + '<li><a href="#home">Home</a></li>' +
'<li><a href="#profile">Profile</a></li>' + '<li><a href="#profile">Profile</a></li>' +
'</ul>' '</ul>'
$('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo('#qunit-fixture') $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo('#qunit-fixture')
$(pillsHTML).find('li:last a').tab('show') $(pillsHTML).find('li:last a').tab('show')
equal($('#qunit-fixture').find('.active').attr('id'), 'profile') equal($('#qunit-fixture').find('.active').attr('id'), 'profile')
$(pillsHTML).find('li:first a').tab('show') $(pillsHTML).find('li:first a').tab('show')
equal($('#qunit-fixture').find('.active').attr('id'), 'home') equal($('#qunit-fixture').find('.active').attr('id'), 'home')
}) })
test('should not fire closed when close is prevented', function () { test('should not fire closed when close is prevented', function () {
$.support.transition = false $.support.transition = false
stop(); stop();
$('<div class="tab"/>') $('<div class="tab"/>')
.on('show.bs.tab', function (e) { .on('show.bs.tab', function (e) {
e.preventDefault(); e.preventDefault();
ok(true); ok(true);
start(); start();
})
.on('shown.bs.tab', function () {
ok(false);
})
.tab('show')
}) })
.on('shown.bs.tab', function () {
test('show and shown events should reference correct relatedTarget', function () { ok(false);
var dropHTML = '<ul class="drop">' + })
'<li class="dropdown"><a data-toggle="dropdown" href="#">1</a>' + .tab('show')
'<ul class="dropdown-menu">' + })
'<li><a href="#1-1" data-toggle="tab">1-1</a></li>' +
'<li><a href="#1-2" data-toggle="tab">1-2</a></li>' + test('show and shown events should reference correct relatedTarget', function () {
'</ul>' + var dropHTML = '<ul class="drop">' +
'</li>' + '<li class="dropdown"><a data-toggle="dropdown" href="#">1</a>' +
'</ul>' '<ul class="dropdown-menu">' +
'<li><a href="#1-1" data-toggle="tab">1-1</a></li>' +
$(dropHTML).find('ul>li:first a').tab('show').end() '<li><a href="#1-2" data-toggle="tab">1-2</a></li>' +
.find('ul>li:last a') '</ul>' +
.on('show.bs.tab', function (event) { '</li>' +
equal(event.relatedTarget.hash, '#1-1') '</ul>'
})
.on('show.bs.tab', function (event) { $(dropHTML).find('ul>li:first a').tab('show').end()
equal(event.relatedTarget.hash, '#1-1') .find('ul>li:last a')
}) .on('show.bs.tab', function (event) {
.tab('show') equal(event.relatedTarget.hash, '#1-1')
})
.on('show.bs.tab', function (event) {
equal(event.relatedTarget.hash, '#1-1')
}) })
.tab('show')
})
}) })
This diff is collapsed.
Markdown is supported
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