Mercurial > wikked
comparison static/bootstrap/js/tests/unit/bootstrap-tab.js @ 88:a5a3d454eac9
Updated Bootstrap.
| author | Ludovic Chabant <ludovic@chabant.com> |
|---|---|
| date | Fri, 05 Apr 2013 08:08:12 -0700 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 87:c0cf67362fb1 | 88:a5a3d454eac9 |
|---|---|
| 1 $(function () { | |
| 2 | |
| 3 module("bootstrap-tabs") | |
| 4 | |
| 5 test("should provide no conflict", function () { | |
| 6 var tab = $.fn.tab.noConflict() | |
| 7 ok(!$.fn.tab, 'tab was set back to undefined (org value)') | |
| 8 $.fn.tab = tab | |
| 9 }) | |
| 10 | |
| 11 test("should be defined on jquery object", function () { | |
| 12 ok($(document.body).tab, 'tabs method is defined') | |
| 13 }) | |
| 14 | |
| 15 test("should return element", function () { | |
| 16 ok($(document.body).tab()[0] == document.body, 'document.body returned') | |
| 17 }) | |
| 18 | |
| 19 test("should activate element by tab id", function () { | |
| 20 var tabsHTML = | |
| 21 '<ul class="tabs">' | |
| 22 + '<li><a href="#home">Home</a></li>' | |
| 23 + '<li><a href="#profile">Profile</a></li>' | |
| 24 + '</ul>' | |
| 25 | |
| 26 $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-fixture") | |
| 27 | |
| 28 $(tabsHTML).find('li:last a').tab('show') | |
| 29 equals($("#qunit-fixture").find('.active').attr('id'), "profile") | |
| 30 | |
| 31 $(tabsHTML).find('li:first a').tab('show') | |
| 32 equals($("#qunit-fixture").find('.active').attr('id'), "home") | |
| 33 }) | |
| 34 | |
| 35 test("should activate element by tab id", function () { | |
| 36 var pillsHTML = | |
| 37 '<ul class="pills">' | |
| 38 + '<li><a href="#home">Home</a></li>' | |
| 39 + '<li><a href="#profile">Profile</a></li>' | |
| 40 + '</ul>' | |
| 41 | |
| 42 $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-fixture") | |
| 43 | |
| 44 $(pillsHTML).find('li:last a').tab('show') | |
| 45 equals($("#qunit-fixture").find('.active').attr('id'), "profile") | |
| 46 | |
| 47 $(pillsHTML).find('li:first a').tab('show') | |
| 48 equals($("#qunit-fixture").find('.active').attr('id'), "home") | |
| 49 }) | |
| 50 | |
| 51 | |
| 52 test("should not fire closed when close is prevented", function () { | |
| 53 $.support.transition = false | |
| 54 stop(); | |
| 55 $('<div class="tab"/>') | |
| 56 .bind('show', function (e) { | |
| 57 e.preventDefault(); | |
| 58 ok(true); | |
| 59 start(); | |
| 60 }) | |
| 61 .bind('shown', function () { | |
| 62 ok(false); | |
| 63 }) | |
| 64 .tab('show') | |
| 65 }) | |
| 66 | |
| 67 test("show and shown events should reference correct relatedTarget", function () { | |
| 68 var dropHTML = | |
| 69 '<ul class="drop">' | |
| 70 + '<li class="dropdown"><a data-toggle="dropdown" href="#">1</a>' | |
| 71 + '<ul class="dropdown-menu">' | |
| 72 + '<li><a href="#1-1" data-toggle="tab">1-1</a></li>' | |
| 73 + '<li><a href="#1-2" data-toggle="tab">1-2</a></li>' | |
| 74 + '</ul>' | |
| 75 + '</li>' | |
| 76 + '</ul>' | |
| 77 | |
| 78 $(dropHTML).find('ul>li:first a').tab('show').end() | |
| 79 .find('ul>li:last a').on('show', function(event){ | |
| 80 equals(event.relatedTarget.hash, "#1-1") | |
| 81 }).on('shown', function(event){ | |
| 82 equals(event.relatedTarget.hash, "#1-1") | |
| 83 }).tab('show') | |
| 84 }) | |
| 85 | |
| 86 }) |
