2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-14 18:42:30 +03:00

Merge branch 'tab-event' of https://github.com/kasperp/bootstrap into kasperp-tab-event

This commit is contained in:
Jacob Thornton
2011-09-29 22:18:08 -07:00
3 changed files with 54 additions and 10 deletions
+30 -8
View File
@@ -11,39 +11,61 @@ $(function () {
})
test("should activate element by tab id", function () {
var tabsHTML = '<ul class="tabs">'
var $tabsHTML = $('<ul class="tabs">'
+ '<li class="active"><a href="#home">Home</a></li>'
+ '<li><a href="#profile">Profile</a></li>'
+ '</ul>'
+ '</ul>')
$('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-runoff")
$(tabsHTML).tabs().find('a').last().click()
$tabsHTML.tabs().find('a').last().click()
equals($("#qunit-runoff").find('.active').attr('id'), "profile")
$(tabsHTML).tabs().find('a').first().click()
$tabsHTML.tabs().find('a').first().click()
equals($("#qunit-runoff").find('.active').attr('id'), "home")
$("#qunit-runoff").empty()
})
test("should activate element by pill id", function () {
var pillsHTML = '<ul class="pills">'
var $pillsHTML = $('<ul class="pills">'
+ '<li class="active"><a href="#home">Home</a></li>'
+ '<li><a href="#profile">Profile</a></li>'
+ '</ul>'
+ '</ul>')
$('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-runoff")
$(pillsHTML).pills().find('a').last().click()
$pillsHTML.pills().find('a').last().click()
equals($("#qunit-runoff").find('.active').attr('id'), "profile")
$(pillsHTML).pills().find('a').first().click()
$pillsHTML.pills().find('a').first().click()
equals($("#qunit-runoff").find('.active').attr('id'), "home")
$("#qunit-runoff").empty()
})
test( "should trigger changed event on activate", function () {
var $tabsHTML = $('<ul class="tabs">'
+ '<li class="active"><a href="#home">Home</a></li>'
+ '<li><a href="#profile">Profile</a></li>'
+ '</ul>')
, changeCount = 0
, from
, to;
$tabsHTML.tabs().bind( "changed", function (e, c){
from = c.from;
to = c.to;
changeCount++
})
$tabsHTML.tabs().find('a').last().click()
equals(from, "#home")
equals(to, "#profile")
equals(changeCount, 1)
})
})