1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*
* tabs_events.js
*/
(function($) {
module("tabs: events");
test('select', function() {
expect(7);
var eventObj;
el = $('#tabs1').tabs({
select: function(event, ui) {
ok(true, 'select triggered after initialization');
equals(this, el[0], "context of callback");
equals(event.type, 'tabsselect', 'event type in callback');
equals(ui.tab, el.find('a')[1], 'contain tab as DOM anchor element');
equals(ui.panel, el.find('div')[1], 'contain panel as DOM div element');
equals(ui.index, 1, 'contain index');
evenObj = event;
}
});
el.tabs('select', 1);
el.find( "li:eq(1) a" ).simulate( "click" );
equals( evenObj.originalEvent.type, "click", "select triggered by click" );
});
test('beforeload', function() {
expect( 5 );
el = $('#tabs2');
el.tabs({
active: 2,
beforeload: function( event, ui ) {
ok( $.isFunction( ui.jqXHR.promise ), 'contain jqXHR object');
equals( ui.settings.url, "data/test.html", 'contain ajax settings url');
equals( ui.tab, el.find('a')[ 2 ], 'contain tab as DOM anchor element');
equals( ui.panel, el.find('div')[ 2 ], 'contain panel as DOM div element');
equals( ui.index, 2, 'contain index');
event.preventDefault();
}
});
});
test('load', function() {
ok(false, "missing test - untested code is broken code.");
});
test('show', function() {
expect(5);
var uiObj, eventObj;
el = $('#tabs1').tabs({
show: function(event, ui) {
uiObj = ui;
eventObj = event;
}
});
ok(uiObj !== undefined, 'trigger callback after initialization');
equals(uiObj.tab, $('a', el)[0], 'contain tab as DOM anchor element');
equals(uiObj.panel, $('div', el)[0], 'contain panel as DOM div element');
equals(uiObj.index, 0, 'contain index');
el.find( "li:eq(1) a" ).simulate( "click" );
equals( eventObj.originalEvent.type, "click", "show triggered by click" );
});
})(jQuery);
|