From 700e742a9cfac5e90ff882a5437e95691b090de0 Mon Sep 17 00:00:00 2001 From: Jason Diamond Date: Sun, 4 Aug 2013 23:59:30 -0700 Subject: failing test for dot in data-parent --- js/tests/unit/collapse.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'js/tests/unit') diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index 73799c75d..11b2cf838 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -126,4 +126,39 @@ $(function () { target3.click() }) + test("should allow dots in data-parent", function () { + $.support.transition = false + stop() + + var accordion = $('
') + .appendTo($('#qunit-fixture')) + + var target1 = $('') + .appendTo(accordion.find('.accordion-group').eq(0)) + + var collapsible1 = $('
') + .appendTo(accordion.find('.accordion-group').eq(0)) + + var target2 = $('') + .appendTo(accordion.find('.accordion-group').eq(1)) + + var collapsible2 = $('
') + .appendTo(accordion.find('.accordion-group').eq(1)) + + var target3 = $('') + .appendTo(accordion.find('.accordion-group').eq(2)) + + var collapsible3 = $('
') + .appendTo(accordion.find('.accordion-group').eq(2)) + .on('show.bs.collapse', function () { + ok(target1.hasClass('collapsed')) + ok(target2.hasClass('collapsed')) + ok(!target3.hasClass('collapsed')) + + start() + }) + + target3.click() + }) + }) -- cgit v1.2.3 From a4f0e8d37ab109c3f4476877854d4aea149fb1f2 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 10 Aug 2013 13:35:20 -0700 Subject: fixes #9111 --- js/tests/unit/modal.js | 301 ++++++++++++++++++++++++++----------------------- 1 file changed, 161 insertions(+), 140 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index 90762ea90..2c610d83d 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -1,156 +1,177 @@ $(function () { - module("modal") + module("modal") - test("should provide no conflict", function () { - var modal = $.fn.modal.noConflict() - ok(!$.fn.modal, 'modal was set back to undefined (org value)') - $.fn.modal = modal - }) + test("should provide no conflict", function () { + var modal = $.fn.modal.noConflict() + ok(!$.fn.modal, 'modal was set back to undefined (org value)') + $.fn.modal = modal + }) - test("should be defined on jquery object", function () { - var div = $("") - ok(div.modal, 'modal method is defined') - }) + test("should be defined on jquery object", function () { + var div = $("") + ok(div.modal, 'modal method is defined') + }) - test("should return element", function () { - var div = $("") - ok(div.modal() == div, 'document.body returned') - $('#modal-test').remove() - }) + test("should return element", function () { + var div = $("") + ok(div.modal() == div, 'document.body returned') + $('#modal-test').remove() + }) - test("should expose defaults var for settings", function () { - ok($.fn.modal.Constructor.DEFAULTS, 'default object exposed') - }) + test("should expose defaults var for settings", function () { + ok($.fn.modal.Constructor.DEFAULTS, 'default object exposed') + }) - test("should insert into dom when show method is called", function () { - stop() - $.support.transition = false - $("") - .on("shown.bs.modal", function () { - ok($('#modal-test').length, 'modal inserted into dom') - $(this).remove() - start() - }) - .modal("show") - }) + test("should insert into dom when show method is called", function () { + stop() + $.support.transition = false + $("") + .on("shown.bs.modal", function () { + ok($('#modal-test').length, 'modal inserted into dom') + $(this).remove() + start() + }) + .modal("show") + }) - test("should fire show event", function () { - stop() - $.support.transition = false - $("") - .on("show.bs.modal", function () { - ok(true, "show was called") - }) - .on("shown.bs.modal", function () { - $(this).remove() - start() - }) - .modal("show") - }) + test("should fire show event", function () { + stop() + $.support.transition = false + $("") + .on("show.bs.modal", function () { + ok(true, "show was called") + }) + .on("shown.bs.modal", function () { + $(this).remove() + start() + }) + .modal("show") + }) - test("should not fire shown when default prevented", function () { - stop() - $.support.transition = false - $("") - .on("show.bs.modal", function (e) { - e.preventDefault() - ok(true, "show was called") - start() - }) - .on("shown.bs.modal", function () { - ok(false, "shown was called") - }) - .modal("show") - }) + test("should not fire shown when default prevented", function () { + stop() + $.support.transition = false + $("") + .on("show.bs.modal", function (e) { + e.preventDefault() + ok(true, "show was called") + start() + }) + .on("shown.bs.modal", function () { + ok(false, "shown was called") + }) + .modal("show") + }) - test("should hide modal when hide is called", function () { - stop() - $.support.transition = false + test("should hide modal when hide is called", function () { + stop() + $.support.transition = false - $("") - .on("shown.bs.modal", function () { - ok($('#modal-test').is(":visible"), 'modal visible') - ok($('#modal-test').length, 'modal inserted into dom') - $(this).modal("hide") - }) - .on("hidden.bs.modal", function() { - ok(!$('#modal-test').is(":visible"), 'modal hidden') - $('#modal-test').remove() - start() - }) - .modal("show") - }) + $("") + .on("shown.bs.modal", function () { + ok($('#modal-test').is(":visible"), 'modal visible') + ok($('#modal-test').length, 'modal inserted into dom') + $(this).modal("hide") + }) + .on("hidden.bs.modal", function() { + ok(!$('#modal-test').is(":visible"), 'modal hidden') + $('#modal-test').remove() + start() + }) + .modal("show") + }) - test("should toggle when toggle is called", function () { - stop() - $.support.transition = false - var div = $("") - div - .on("shown.bs.modal", function () { - ok($('#modal-test').is(":visible"), 'modal visible') - ok($('#modal-test').length, 'modal inserted into dom') - div.modal("toggle") - }) - .on("hidden.bs.modal", function() { - ok(!$('#modal-test').is(":visible"), 'modal hidden') - div.remove() - start() - }) - .modal("toggle") - }) + test("should toggle when toggle is called", function () { + stop() + $.support.transition = false + var div = $("") + div + .on("shown.bs.modal", function () { + ok($('#modal-test').is(":visible"), 'modal visible') + ok($('#modal-test').length, 'modal inserted into dom') + div.modal("toggle") + }) + .on("hidden.bs.modal", function() { + ok(!$('#modal-test').is(":visible"), 'modal hidden') + div.remove() + start() + }) + .modal("toggle") + }) - test("should remove from dom when click [data-dismiss=modal]", function () { - stop() - $.support.transition = false - var div = $("") - div - .on("shown.bs.modal", function () { - ok($('#modal-test').is(":visible"), 'modal visible') - ok($('#modal-test').length, 'modal inserted into dom') - div.find('.close').click() - }) - .on("hidden.bs.modal", function() { - ok(!$('#modal-test').is(":visible"), 'modal hidden') - div.remove() - start() - }) - .modal("toggle") - }) + test("should remove from dom when click [data-dismiss=modal]", function () { + stop() + $.support.transition = false + var div = $("") + div + .on("shown.bs.modal", function () { + ok($('#modal-test').is(":visible"), 'modal visible') + ok($('#modal-test').length, 'modal inserted into dom') + div.find('.close').click() + }) + .on("hidden.bs.modal", function() { + ok(!$('#modal-test').is(":visible"), 'modal hidden') + div.remove() + start() + }) + .modal("toggle") + }) - test("should allow modal close with 'backdrop:false'", function () { - stop() - $.support.transition = false - var div = $("
", { id: 'modal-test', "data-backdrop": false }) - div - .on("shown.bs.modal", function () { - ok($('#modal-test').is(":visible"), 'modal visible') - div.modal("hide") - }) - .on("hidden.bs.modal", function() { - ok(!$('#modal-test').is(":visible"), 'modal hidden') - div.remove() - start() - }) - .modal("show") - }) + test("should allow modal close with 'backdrop:false'", function () { + stop() + $.support.transition = false + var div = $("
", { id: 'modal-test', "data-backdrop": false }) + div + .on("shown.bs.modal", function () { + ok($('#modal-test').is(":visible"), 'modal visible') + div.modal("hide") + }) + .on("hidden.bs.modal", function() { + ok(!$('#modal-test').is(":visible"), 'modal hidden') + div.remove() + start() + }) + .modal("show") + }) - test("should close modal when clicking outside of modal-content", function () { - stop() - $.support.transition = false - var div = $("") - div - .bind("shown.bs.modal", function () { - ok($('#modal-test').length, 'modal insterted into dom') - $('.contents').click() - ok($('#modal-test').is(":visible"), 'modal visible') - $('#modal-test').click() - }) - .bind("hidden.bs.modal", function() { - ok(!$('#modal-test').is(":visible"), 'modal hidden') - div.remove() - start() - }) - .modal("show") - }) + test("should close modal when clicking outside of modal-content", function () { + stop() + $.support.transition = false + var div = $("") + div + .bind("shown.bs.modal", function () { + ok($('#modal-test').length, 'modal insterted into dom') + $('.contents').click() + ok($('#modal-test').is(":visible"), 'modal visible') + $('#modal-test').click() + }) + .bind("hidden.bs.modal", function() { + ok(!$('#modal-test').is(":visible"), 'modal hidden') + div.remove() + start() + }) + .modal("show") + }) + + test("should trigger hide event once when clicking outside of modal-content", function () { + stop() + $.support.transition = false + var div = $("") + var triggered + div + .bind("shown.bs.modal", function () { + triggered = 0 + $('#modal-test').click() + }) + .one("hidden.bs.modal", function() { + div.modal("show") + }) + .bind("hide.bs.modal", function () { + triggered += 1 + ok(triggered === 1, 'modal hide triggered once') + start() + }) + .modal("show") + }) }) -- cgit v1.2.3 From 712b89ed4ebe71e44f2a7081be7ba372d8ca3f42 Mon Sep 17 00:00:00 2001 From: fat Date: Sat, 17 Aug 2013 14:24:38 -0700 Subject: fixes #9362 --- js/tests/unit/modal.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'js/tests/unit') diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index 2c610d83d..5755d2751 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -174,4 +174,23 @@ $(function () { }) .modal("show") }) + + test("should close reopened modal with [data-dismiss=modal] click", function () { + stop() + $.support.transition = false + var div = $("") + div + .bind("shown.bs.modal", function () { + $('#close').click() + ok(!$('#modal-test').is(":visible"), 'modal hidden') + }) + .one("hidden.bs.modal", function() { + div.one('hidden.bs.modal', function () { + start() + }).modal("show") + }) + .modal("show") + + div.remove() + }) }) -- cgit v1.2.3