From 667179f406ea66fbe2d688bb132eaa0c0f7383a6 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Thu, 20 Sep 2012 16:23:54 -0700 Subject: added support for jquery 1.8.* --- js/tests/unit/bootstrap-popover.js | 8 ++++---- js/tests/unit/bootstrap-tooltip.js | 14 +++++++------- js/tests/unit/bootstrap-typeahead.js | 17 ++++++----------- 3 files changed, 17 insertions(+), 22 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/bootstrap-popover.js b/js/tests/unit/bootstrap-popover.js index 04d5279d2..1331e5d3d 100644 --- a/js/tests/unit/bootstrap-popover.js +++ b/js/tests/unit/bootstrap-popover.js @@ -94,14 +94,14 @@ $(function () { test("should destroy popover", function () { var popover = $('
').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') + ok($._data(popover[0], 'events').mouseover && $._data(popover[0], 'events').mouseout, 'popover has hover event') + ok($._data((popover[0], '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') + ok($._data(popover[0],'events').click[0].namespace == 'foo', 'popover still has click.foo') + ok(!$._data(popover[0], 'events').mouseover && !$._data(popover[0], 'events').mouseout, 'popover does not have any events') }) }) \ No newline at end of file diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js index 9844d6460..14d6b2274 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -113,7 +113,7 @@ $(function () { }, 50) }) - test("should show tooltip if leave event hasn't occurred before delay expires", function () { + test("should show tooltip if leave event hasn't occured before delay expires", function () { var tooltip = $('') .appendTo('#qunit-fixture') .tooltip({ delay: 150 }) @@ -131,14 +131,14 @@ $(function () { test("should destroy tooltip", function () { var tooltip = $('
').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') + ok($._data(tooltip[0], 'events').mouseover && $._data(tooltip[0], 'events').mouseout, 'tooltip has hover event') + ok($._data(tooltip[0], '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') + ok(!$._data(tooltip[0], 'tooltip'), 'tooltip does not have data') + ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip still has click.foo') + ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events') }) -}) +}) \ No newline at end of file diff --git a/js/tests/unit/bootstrap-typeahead.js b/js/tests/unit/bootstrap-typeahead.js index eb447aaa6..16bdb9194 100644 --- a/js/tests/unit/bootstrap-typeahead.js +++ b/js/tests/unit/bootstrap-typeahead.js @@ -13,14 +13,9 @@ $(function () { test("should listen to an input", function () { var $input = $('') $input.typeahead() - ok($input.data('events').blur, 'has a blur event') - ok($input.data('events').keypress, 'has a keypress event') - ok($input.data('events').keyup, 'has a keyup event') - if ($.browser.webkit || $.browser.msie) { - ok($input.data('events').keydown, 'has a keydown event') - } else { - ok($input.data('events').keydown, 'does not have a keydown event') - } + ok($._data($input[0], 'events').blur, 'has a blur event') + ok($._data($input[0], 'events').keypress, 'has a keypress event') + ok($._data($input[0], 'events').keyup, 'has a keyup event') }) test("should create a menu", function () { @@ -32,8 +27,8 @@ $(function () { var $input = $('') , $menu = $input.typeahead().data('typeahead').$menu - ok($menu.data('events').mouseover, 'has a mouseover(pseudo: mouseenter)') - ok($menu.data('events').click, 'has a click') + ok($._data($menu[0], 'events').mouseover, 'has a mouseover(pseudo: mouseenter)') + ok($._data($menu[0], 'events').click, 'has a click') }) test("should show menu when query entered", function () { @@ -201,4 +196,4 @@ $(function () { typeahead.$menu.remove() }) -}) +}) \ No newline at end of file -- cgit v1.2.3 From fe38d12f122cc0a9e3435ffa0d7de58b6fa941f4 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Thu, 20 Sep 2012 16:26:00 -0700 Subject: rebuild - fix missing ( --- js/tests/unit/bootstrap-popover.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/bootstrap-popover.js b/js/tests/unit/bootstrap-popover.js index 1331e5d3d..6a5f0bdcf 100644 --- a/js/tests/unit/bootstrap-popover.js +++ b/js/tests/unit/bootstrap-popover.js @@ -95,7 +95,7 @@ $(function () { var popover = $('
').popover({trigger: 'hover'}).on('click.foo', function(){}) ok(popover.data('popover'), 'popover has data') ok($._data(popover[0], 'events').mouseover && $._data(popover[0], 'events').mouseout, 'popover has hover event') - ok($._data((popover[0], 'events').click[0].namespace == 'foo', 'popover has extra click.foo event') + ok($._data(popover[0], 'events').click[0].namespace == 'foo', 'popover has extra click.foo event') popover.popover('show') popover.popover('destroy') ok(!popover.hasClass('in'), 'popover is hidden') -- cgit v1.2.3 From 1716b0fdb5023ff45f0d28e5266db053aa64ccc6 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Thu, 20 Sep 2012 16:31:10 -0700 Subject: remove src's --- js/tests/unit/bootstrap-carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/bootstrap-carousel.js b/js/tests/unit/bootstrap-carousel.js index 4c93c7b18..5ac9fb2d8 100644 --- a/js/tests/unit/bootstrap-carousel.js +++ b/js/tests/unit/bootstrap-carousel.js @@ -26,7 +26,7 @@ $(function () { }) test("should fire slide event with relatedTarget", function () { - var template = '' + var template = '' $.support.transition = false stop() $(template) -- cgit v1.2.3 From 003fcccceb869ac0420d542bac9860f5f32e68a1 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Mon, 24 Sep 2012 23:15:36 -0700 Subject: change tooltip/popover html default to false for xss safety net --- js/tests/unit/bootstrap-tooltip.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js index 14d6b2274..964ba1ef2 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -37,10 +37,11 @@ $(function () { tooltip.tooltip('hide') }) - test("should always allow html entities", function () { + test("should allow html entities", function () { $.support.transition = false var tooltip = $('') .appendTo('#qunit-fixture') + .tooltip({html: true}) .tooltip('show') ok($('.tooltip b').length, 'b tag was inserted') -- cgit v1.2.3 From e9a648cd39dc6b5e0f126b7272adeac816ece758 Mon Sep 17 00:00:00 2001 From: Erlend Halvorsen Date: Thu, 27 Sep 2012 10:31:40 +0200 Subject: Fixed bug in dropdown toggle where menu would only clear on the first drop down --- js/tests/unit/bootstrap-dropdown.js | 42 ++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/bootstrap-dropdown.js b/js/tests/unit/bootstrap-dropdown.js index 3a617692b..3788209ec 100644 --- a/js/tests/unit/bootstrap-dropdown.js +++ b/js/tests/unit/bootstrap-dropdown.js @@ -7,7 +7,8 @@ $(function () { }) test("should return element", function () { - ok($(document.body).dropdown()[0] == document.body, 'document.body returned') + var el = $("
") + ok(el.dropdown()[0] === el[0], 'same element returned') }) test("should not open dropdown if target is disabled", function () { @@ -102,4 +103,43 @@ $(function () { dropdown.remove() }) + test("should remove open class if body clicked, with multiple drop downs", function () { + var dropdownHTML = + '' + + '
' + + ' ' + + ' ' + + ' ' + + '
' + , dropdowns = $(dropdownHTML).appendTo('#qunit-fixture').find('[data-toggle="dropdown"]') + , first = dropdowns.first() + , last = dropdowns.last() + + ok(dropdowns.length == 2, "Should be two dropdowns") + + first.click() + ok(first.parents('.open').length == 1, 'open class added on click') + ok($('#qunit-fixture .open').length == 1, 'only one object is open') + $('body').click() + ok($("#qunit-fixture .open").length === 0, 'open class removed') + + last.click() + ok(last.parent('.open').length == 1, 'open class added on click') + ok($('#qunit-fixture .open').length == 1, 'only one object is open') + $('body').click() + ok($("#qunit-fixture .open").length === 0, 'open class removed') + + $("#qunit-fixture").html("") + }) + }) \ No newline at end of file -- cgit v1.2.3 From 48a8dd2a23f11981d42785db4091c029b5b7e781 Mon Sep 17 00:00:00 2001 From: Kevin Attfield Date: Mon, 8 Oct 2012 22:29:44 -0700 Subject: Added test to fix for #5362 --- js/tests/unit/bootstrap-tab.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'js/tests/unit') diff --git a/js/tests/unit/bootstrap-tab.js b/js/tests/unit/bootstrap-tab.js index 987804781..40f9a7406 100644 --- a/js/tests/unit/bootstrap-tab.js +++ b/js/tests/unit/bootstrap-tab.js @@ -58,4 +58,23 @@ $(function () { .tab('show') }) + test("show and shown events should reference correct relatedTarget", function () { + var dropHTML = + '
    ' + + '' + + '
' + + $(dropHTML).find('ul>li:first a').tab('show').end() + .find('ul>li:last a').on('show', function(event){ + equals(event.relatedTarget.hash, "#1-1") + }).on('shown', function(event){ + equals(event.relatedTarget.hash, "#1-1") + }).tab('show') + }) + }) \ No newline at end of file -- cgit v1.2.3 From 6b017b9bea37629d0ee9bcd99e8e34b91aa3b5c0 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 15 Oct 2012 15:17:59 +0200 Subject: fixed reference to this.tip() so it works in delegate events --- js/tests/unit/bootstrap-tooltip.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/tests/unit') diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js index 964ba1ef2..bbdf3ce80 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -142,4 +142,12 @@ $(function () { ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events') }) + test("should show tooltip with delegate selector on click", function () { + var div = $('
') + var tooltip = div.appendTo('#qunit-fixture') + .tooltip({ selector: 'a[rel=tooltip]', + trigger: 'click' }) + div.find('a').trigger('click') + ok($(".tooltip").is('.fade.in'), 'tooltip is faded in') + }) }) \ No newline at end of file -- cgit v1.2.3 From 432eaff29cc05f488fc0a1c87d1e28d86ef3641e Mon Sep 17 00:00:00 2001 From: dmitriybudnik Date: Mon, 15 Oct 2012 21:55:32 +0300 Subject: Fixed copy/paste caused typo --- js/tests/unit/bootstrap-carousel.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/bootstrap-carousel.js b/js/tests/unit/bootstrap-carousel.js index 5ac9fb2d8..fbcbb5b17 100644 --- a/js/tests/unit/bootstrap-carousel.js +++ b/js/tests/unit/bootstrap-carousel.js @@ -37,6 +37,26 @@ $(function () { start(); }) .carousel('next') - }) + test("should set interval from data attribute", function () { + var template = $(''); + template.attr("data-interval", 1814); + + template.appendTo("body"); + $('[data-slide]').first().click(); + ok($('#myCarousel').data('carousel').options.interval == 1814); + $('#myCarousel').remove(); + + template.appendTo("body").attr("data-modal", "foobar"); + $('[data-slide]').first().click(); + ok($('#myCarousel').data('carousel').options.interval == 1814, "even if there is an data-modal attribute set"); + $('#myCarousel').remove(); + + template.appendTo("body"); + $('[data-slide]').first().click(); + $('#myCarousel').attr('data-interval', 1860); + $('[data-slide]').first().click(); + ok($('#myCarousel').data('carousel').options.interval == 1814, "attributes should be read only on intitialization"); + $('#myCarousel').remove(); + }) }) \ No newline at end of file -- cgit v1.2.3 From cd5596393049e5c22f17f7f99764be1bfbc43ecc Mon Sep 17 00:00:00 2001 From: Dmitriy Budnik Date: Tue, 16 Oct 2012 09:49:01 +0300 Subject: fixed test --- js/tests/unit/bootstrap-carousel.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/bootstrap-carousel.js b/js/tests/unit/bootstrap-carousel.js index fbcbb5b17..97ea942de 100644 --- a/js/tests/unit/bootstrap-carousel.js +++ b/js/tests/unit/bootstrap-carousel.js @@ -37,11 +37,12 @@ $(function () { start(); }) .carousel('next') + }) test("should set interval from data attribute", function () { var template = $(''); template.attr("data-interval", 1814); - + template.appendTo("body"); $('[data-slide]').first().click(); ok($('#myCarousel').data('carousel').options.interval == 1814); @@ -51,7 +52,7 @@ $(function () { $('[data-slide]').first().click(); ok($('#myCarousel').data('carousel').options.interval == 1814, "even if there is an data-modal attribute set"); $('#myCarousel').remove(); - + template.appendTo("body"); $('[data-slide]').first().click(); $('#myCarousel').attr('data-interval', 1860); -- cgit v1.2.3 From ae0ba0686efcbf73116a21eb9aff3f9bede4a489 Mon Sep 17 00:00:00 2001 From: Dmitriy Budnik Date: Tue, 16 Oct 2012 11:16:38 +0300 Subject: set spesific assertions count for test --- js/tests/unit/bootstrap-carousel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/bootstrap-carousel.js b/js/tests/unit/bootstrap-carousel.js index 97ea942de..8bd1b62ba 100644 --- a/js/tests/unit/bootstrap-carousel.js +++ b/js/tests/unit/bootstrap-carousel.js @@ -39,7 +39,7 @@ $(function () { .carousel('next') }) - test("should set interval from data attribute", function () { + test("should set interval from data attribute", 3,function () { var template = $(''); template.attr("data-interval", 1814); -- cgit v1.2.3