From 895b0006b9adbaf3c56953d2ab2967aa85071086 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 13 Feb 2014 09:55:12 +0200 Subject: [PATCH] Re-indent test files. --- js/.jshintrc | 1 + js/tests/unit/affix.js | 88 ++--- js/tests/unit/alert.js | 110 +++--- js/tests/unit/button.js | 206 +++++----- js/tests/unit/carousel.js | 192 +++++----- js/tests/unit/collapse.js | 302 +++++++-------- js/tests/unit/dropdown.js | 418 ++++++++++---------- js/tests/unit/modal.js | 368 +++++++++--------- js/tests/unit/popover.js | 242 ++++++------ js/tests/unit/scrollspy.js | 54 +-- js/tests/unit/tab.js | 152 ++++---- js/tests/unit/tooltip.js | 758 ++++++++++++++++++------------------- 12 files changed, 1446 insertions(+), 1445 deletions(-) diff --git a/js/.jshintrc b/js/.jshintrc index ab4dfdfc98..ec49259641 100644 --- a/js/.jshintrc +++ b/js/.jshintrc @@ -8,6 +8,7 @@ "eqeqeq" : false, "eqnull" : true, "expr" : true, + "indent" : 2, "laxbreak" : true, "quotmark" : "single", "validthis": true diff --git a/js/tests/unit/affix.js b/js/tests/unit/affix.js index 3c8105bceb..b348ecf2b5 100644 --- a/js/tests/unit/affix.js +++ b/js/tests/unit/affix.js @@ -1,50 +1,50 @@ $(function () { - module('affix') + module('affix') - test('should provide no conflict', function () { - var affix = $.fn.affix.noConflict() - ok(!$.fn.affix, 'affix was set back to undefined (org value)') - $.fn.affix = affix + test('should provide no conflict', function () { + var affix = $.fn.affix.noConflict() + ok(!$.fn.affix, 'affix was set back to undefined (org value)') + $.fn.affix = 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 = $('
').affix() + $affix.data('bs.affix').checkPosition() + ok(!$affix.hasClass('affix'), 'affix class was not added') + }) + + test('should trigger affixed event after affix', function () { + stop() + + var template = $('
') + 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 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 = $('
').affix() - $affix.data('bs.affix').checkPosition() - ok(!$affix.hasClass('affix'), 'affix class was not added') - }) - - test('should trigger affixed event after affix', function () { - stop() - - var template = $('
') - 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) - }) + setTimeout(function () { + window.scrollTo(0, document.body.scrollHeight) + setTimeout(function () { window.scroll(0,0) }, 0) + },0) + }) }) diff --git a/js/tests/unit/alert.js b/js/tests/unit/alert.js index b88b95fee5..755d9d1e55 100644 --- a/js/tests/unit/alert.js +++ b/js/tests/unit/alert.js @@ -1,62 +1,62 @@ $(function () { - module('alert') + module('alert') - test('should provide no conflict', function () { - var alert = $.fn.alert.noConflict() - ok(!$.fn.alert, 'alert was set back to undefined (org value)') - $.fn.alert = alert + test('should provide no conflict', function () { + var alert = $.fn.alert.noConflict() + ok(!$.fn.alert, 'alert was set back to undefined (org value)') + $.fn.alert = alert + }) + + test('should be defined on jquery object', function () { + ok($(document.body).alert, 'alert method is defined') + }) + + test('should return element', function () { + ok($(document.body).alert()[0] == document.body, 'document.body returned') + }) + + test('should fade element out on clicking .close', function () { + var alertHTML = '
' + + '×' + + '

Holy guacamole! Best check yo self, you\'re not looking too good.

' + + '
', + alert = $(alertHTML).alert() + + alert.find('.close').click() + + ok(!alert.hasClass('in'), 'remove .in class on .close click') + }) + + test('should remove element when clicking .close', function () { + $.support.transition = false + + var alertHTML = '
' + + '×' + + '

Holy guacamole! Best check yo self, you\'re not looking too good.

' + + '
', + alert = $(alertHTML).appendTo('#qunit-fixture').alert() + + ok($('#qunit-fixture').find('.alert-message').length, 'element added to dom') + + alert.find('.close').click() + + 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(); + $('
') + .on('close.bs.alert', function (e) { + e.preventDefault(); + ok(true); + start(); }) - - test('should be defined on jquery object', function () { - ok($(document.body).alert, 'alert method is defined') - }) - - test('should return element', function () { - ok($(document.body).alert()[0] == document.body, 'document.body returned') - }) - - test('should fade element out on clicking .close', function () { - var alertHTML = '
' + - '×' + - '

Holy guacamole! Best check yo self, you\'re not looking too good.

' + - '
', - alert = $(alertHTML).alert() - - alert.find('.close').click() - - ok(!alert.hasClass('in'), 'remove .in class on .close click') - }) - - test('should remove element when clicking .close', function () { - $.support.transition = false - - var alertHTML = '
' + - '×' + - '

Holy guacamole! Best check yo self, you\'re not looking too good.

' + - '
', - alert = $(alertHTML).appendTo('#qunit-fixture').alert() - - ok($('#qunit-fixture').find('.alert-message').length, 'element added to dom') - - alert.find('.close').click() - - 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(); - $('
') - .on('close.bs.alert', function (e) { - e.preventDefault(); - ok(true); - start(); - }) - .on('closed.bs.alert', function () { - ok(false); - }) - .alert('close') + .on('closed.bs.alert', function () { + ok(false); }) + .alert('close') + }) }) diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index 104e8d8577..73420863ce 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -1,122 +1,122 @@ $(function () { - module('button') + module('button') - test('should provide no conflict', function () { - var button = $.fn.button.noConflict() - ok(!$.fn.button, 'button was set back to undefined (org value)') - $.fn.button = button - }) + test('should provide no conflict', function () { + var button = $.fn.button.noConflict() + ok(!$.fn.button, 'button was set back to undefined (org value)') + $.fn.button = button + }) - test('should be defined on jquery object', function () { - ok($(document.body).button, 'button method is defined') - }) + test('should be defined on jquery object', function () { + ok($(document.body).button, 'button method is defined') + }) - test('should return element', function () { - ok($(document.body).button()[0] == document.body, 'document.body returned') - }) + test('should return element', function () { + ok($(document.body).button()[0] == document.body, 'document.body returned') + }) - test('should return set state to loading', function () { - var btn = $('') - equal(btn.html(), 'mdo', 'btn text equals mdo') - btn.button('loading') - equal(btn.html(), 'fat', 'btn text equals fat') - stop() - setTimeout(function () { - ok(btn.attr('disabled'), 'btn is disabled') - ok(btn.hasClass('disabled'), 'btn has disabled class') - start() - }, 0) - }) + test('should return set state to loading', function () { + var btn = $('') + equal(btn.html(), 'mdo', 'btn text equals mdo') + btn.button('loading') + equal(btn.html(), 'fat', 'btn text equals fat') + stop() + setTimeout(function () { + ok(btn.attr('disabled'), 'btn is disabled') + ok(btn.hasClass('disabled'), 'btn has disabled class') + start() + }, 0) + }) - test('should return reset state', function () { - var btn = $('') - equal(btn.html(), 'mdo', 'btn text equals mdo') - btn.button('loading') - equal(btn.html(), 'fat', 'btn text equals fat') - stop() - setTimeout(function () { - ok(btn.attr('disabled'), 'btn is disabled') - ok(btn.hasClass('disabled'), 'btn has disabled class') - start() - stop() - btn.button('reset') - equal(btn.html(), 'mdo', 'btn text equals mdo') - setTimeout(function () { - ok(!btn.attr('disabled'), 'btn is not disabled') - ok(!btn.hasClass('disabled'), 'btn does not have disabled class') - start() - }, 0) - }, 0) + test('should return reset state', function () { + var btn = $('') + equal(btn.html(), 'mdo', 'btn text equals mdo') + btn.button('loading') + equal(btn.html(), 'fat', 'btn text equals fat') + stop() + setTimeout(function () { + ok(btn.attr('disabled'), 'btn is disabled') + ok(btn.hasClass('disabled'), 'btn has disabled class') + start() + stop() + btn.button('reset') + equal(btn.html(), 'mdo', 'btn text equals mdo') + setTimeout(function () { + ok(!btn.attr('disabled'), 'btn is not disabled') + ok(!btn.hasClass('disabled'), 'btn does not have disabled class') + start() + }, 0) + }, 0) - }) + }) - test('should toggle active', function () { - var btn = $('') - ok(!btn.hasClass('active'), 'btn does not have active class') - btn.button('toggle') - ok(btn.hasClass('active'), 'btn has class active') - }) + test('should toggle active', function () { + var btn = $('') + ok(!btn.hasClass('active'), 'btn does not have active class') + btn.button('toggle') + ok(btn.hasClass('active'), 'btn has class active') + }) - test('should toggle active when btn children are clicked', function () { - var btn = $(''), - inner = $('') - btn - .append(inner) - .appendTo($('#qunit-fixture')) - ok(!btn.hasClass('active'), 'btn does not have active class') - inner.click() - ok(btn.hasClass('active'), 'btn has class active') - }) + test('should toggle active when btn children are clicked', function () { + var btn = $(''), + inner = $('') + btn + .append(inner) + .appendTo($('#qunit-fixture')) + ok(!btn.hasClass('active'), 'btn does not have active class') + inner.click() + ok(btn.hasClass('active'), 'btn has class active') + }) - test('should toggle active when btn children are clicked within btn-group', function () { - var btngroup = $('
'), - btn = $(''), - inner = $('') - btngroup - .append(btn.append(inner)) - .appendTo($('#qunit-fixture')) - ok(!btn.hasClass('active'), 'btn does not have active class') - inner.click() - ok(btn.hasClass('active'), 'btn has class active') - }) + test('should toggle active when btn children are clicked within btn-group', function () { + var btngroup = $('
'), + btn = $(''), + inner = $('') + btngroup + .append(btn.append(inner)) + .appendTo($('#qunit-fixture')) + ok(!btn.hasClass('active'), 'btn does not have active class') + inner.click() + ok(btn.hasClass('active'), 'btn has class active') + }) - test('should check for closest matching toggle', function () { - var group = '
' + - '' + - '' + - '' + - '
' + test('should check for closest matching toggle', function () { + var group = '
' + + '' + + '' + + '' + + '
' - group = $(group) + group = $(group) - var btn1 = $(group.children()[0]) - var btn2 = $(group.children()[1]) - var btn3 = $(group.children()[2]) + var btn1 = $(group.children()[0]) + var btn2 = $(group.children()[1]) + var btn3 = $(group.children()[2]) - group.appendTo($('#qunit-fixture')) + group.appendTo($('#qunit-fixture')) - ok(btn1.hasClass('active'), 'btn1 has active class') - ok(btn1.find('input').prop('checked'), 'btn1 is checked') - ok(!btn2.hasClass('active'), 'btn2 does not have active class') - ok(!btn2.find('input').prop('checked'), 'btn2 is not checked') - btn2.find('input').click() - ok(!btn1.hasClass('active'), 'btn1 does not have active class') - ok(!btn1.find('input').prop('checked'), 'btn1 is checked') - ok(btn2.hasClass('active'), 'btn2 has active class') - ok(btn2.find('input').prop('checked'), 'btn2 is checked') + ok(btn1.hasClass('active'), 'btn1 has active class') + ok(btn1.find('input').prop('checked'), 'btn1 is checked') + ok(!btn2.hasClass('active'), 'btn2 does not have active class') + ok(!btn2.find('input').prop('checked'), 'btn2 is not checked') + btn2.find('input').click() + ok(!btn1.hasClass('active'), 'btn1 does not have active class') + ok(!btn1.find('input').prop('checked'), 'btn1 is checked') + ok(btn2.hasClass('active'), 'btn2 has active class') + ok(btn2.find('input').prop('checked'), 'btn2 is checked') - 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.find('input').prop('checked'), 'btn1 is checked') - ok(btn2.hasClass('active'), 'btn2 has active class') - ok(btn2.find('input').prop('checked'), 'btn2 is checked') - }) + 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.find('input').prop('checked'), 'btn1 is checked') + ok(btn2.hasClass('active'), 'btn2 has active class') + ok(btn2.find('input').prop('checked'), 'btn2 is checked') + }) }) diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js index 5edec68adb..6851e17a5e 100644 --- a/js/tests/unit/carousel.js +++ b/js/tests/unit/carousel.js @@ -1,110 +1,110 @@ $(function () { - module('carousel') + module('carousel') - test('should provide no conflict', function () { - var carousel = $.fn.carousel.noConflict() - ok(!$.fn.carousel, 'carousel was set back to undefined (org value)') - $.fn.carousel = carousel + test('should provide no conflict', function () { + var carousel = $.fn.carousel.noConflict() + ok(!$.fn.carousel, 'carousel was set back to undefined (org value)') + $.fn.carousel = carousel + }) + + test('should be defined on jquery object', function () { + ok($(document.body).carousel, 'carousel method is defined') + }) + + test('should return element', function () { + ok($(document.body).carousel()[0] == document.body, 'document.body returned') + }) + + test('should not fire slide when slide is prevented', function () { + $.support.transition = false + stop() + $('