From bf9d8fcc070fa826c342282e102fe00e1af76d10 Mon Sep 17 00:00:00 2001 From: Matt Morgan Date: Thu, 26 Apr 2012 14:09:20 -0400 Subject: Alter typeahead to accept synchronous/asynchronous data source via function/callback --- js/tests/unit/bootstrap-typeahead.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'js/tests/unit') diff --git a/js/tests/unit/bootstrap-typeahead.js b/js/tests/unit/bootstrap-typeahead.js index 4e2428d6a..25d4cafd8 100644 --- a/js/tests/unit/bootstrap-typeahead.js +++ b/js/tests/unit/bootstrap-typeahead.js @@ -52,6 +52,42 @@ $(function () { typeahead.$menu.remove() }) + test("should accept data source via synchronous function", function () { + var $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 = $('').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 = $('').typeahead({ source: ['aa', 'ab', 'ac', 'mdo*', 'fat+'] -- cgit v1.2.3 From 5b401a8c16bf54aad4df38790d20f05bfea03822 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 2 Jun 2012 17:28:38 -0700 Subject: add collapsed class to collapse invoker when it's target is collapsed #3525 --- js/tests/unit/bootstrap-collapse.js | 38 +++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/bootstrap-collapse.js b/js/tests/unit/bootstrap-collapse.js index fb66135db..6cc7ac7a4 100644 --- a/js/tests/unit/bootstrap-collapse.js +++ b/js/tests/unit/bootstrap-collapse.js @@ -24,7 +24,7 @@ $(function () { test("should not fire shown when show is prevented", function () { $.support.transition = false - stop(); + stop() $('
') .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() $('
') .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 = $('') + .appendTo($('#qunit-fixture')) + + var collapsible = $('
') + .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 = $('') + .appendTo($('#qunit-fixture')) + + var collapsible = $('
') + .appendTo($('#qunit-fixture')) + .on('hide', function () { + ok(target.hasClass('collapsed')) + start() + }) + + target.click() + }) + }) \ No newline at end of file -- cgit v1.2.3 From 037107480de9dd11095553ee409cbc748b5c7a68 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 2 Jun 2012 17:57:36 -0700 Subject: remove isHTML support --- js/tests/unit/bootstrap-tooltip.js | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js index 7b0c10de0..51e03486e 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -128,28 +128,4 @@ $(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('
foo
'), '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
foo
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($('
')), 'correctly detected html') - }) - }) -- cgit v1.2.3 From 806a82ef8326e9a7b9b21fce91b827f478298519 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 2 Jun 2012 18:06:00 -0700 Subject: add relatedTarget to carousel slide event --- js/tests/unit/bootstrap-carousel.js | 16 +++++++++++++++- 1 file changed, 15 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 92c23e227..4c93c7b18 100644 --- a/js/tests/unit/bootstrap-carousel.js +++ b/js/tests/unit/bootstrap-carousel.js @@ -12,7 +12,7 @@ $(function () { test("should not fire sliden when slide is prevented", function () { $.support.transition = false - stop(); + stop() $('