| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 /* 2 * tabs_methods.js 3 */ 4 (function($) { 5 6 module("tabs: methods"); 7 8 test('init', function() { 9 expect(9); 10 11 el = $('#tabs1').tabs(); 12 13 ok(true, '.tabs() called on element'); 14 ok( el.is('.ui-tabs.ui-widget.ui-widget-content.ui-corner-all'), 'attach classes to container'); 15 ok( $('ul', el).is('.ui-tabs-nav.ui-helper-reset.ui-helper-clearfix.ui-widget-header.ui-corner-all'), 'attach classes to list' ); 16 ok( $('div:eq(0)', el).is('.ui-tabs-panel.ui-widget-content.ui-corner-bottom'), 'attach classes to panel' ); 17 ok( $('li:eq(0)', el).is('.ui-tabs-selected.ui-state-active.ui-corner-top'), 'attach classes to active li'); 18 ok( $('li:eq(1)', el).is('.ui-state-default.ui-corner-top'), 'attach classes to inactive li'); 19 equals( el.data('selected.tabs'), 0, 'selected.tabs set' ); 20 equals( $('li', el).index( $('li.ui-tabs-selected', el) ), 0, 'second tab active'); 21 equals( $('div', el).index( $('div.ui-tabs-hide', '#tabs1') ), 1, 'second panel should be hidden' ); 22 }); 23 24 test('destroy', function() { 25 expect(6); 26 27 el = $('#tabs1').tabs({ collapsible: true }); 28 $('li:eq(2)', el).simulate('mouseover').find('a').focus(); 29 el.tabs('destroy'); 30 31 ok( el.is(':not(.ui-tabs, .ui-widget, .ui-widget-content, .ui-corner-all, .ui-tabs-collapsible)'), 'remove classes from container'); 32 ok( $('ul', el).is(':not(.ui-tabs-nav, .ui-helper-reset, .ui-helper-clearfix, .ui-widget-header, .ui-corner-all)'), 'remove classes from list' ); 33 ok( $('div:eq(1)', el).is(':not(.ui-tabs-panel, .ui-widget-content, .ui-corner-bottom, .ui-tabs-hide)'), 'remove classes to panel' ); 34 ok( $('li:eq(0)', el).is(':not(.ui-tabs-selected, .ui-state-active, .ui-corner-top)'), 'remove classes from active li'); 35 ok( $('li:eq(1)', el).is(':not(.ui-state-default, .ui-corner-top)'), 'remove classes from inactive li'); 36 ok( $('li:eq(2)', el).is(':not(.ui-state-hover, .ui-state-focus)'), 'remove classes from mouseovered or focused li'); 37 }); 38 39 test('enable', function() { 40 ok(false, "missing test - untested code is broken code."); 41 }); 42 43 test('disable', function() { 44 ok(false, "missing test - untested code is broken code."); 45 }); 46 47 test('add', function() { 48 expect(4); 49 50 el = $('#tabs1').tabs(); 51 el.tabs('add', "#new", 'New'); 52 53 var added = $('li:last', el).simulate('mouseover'); 54 ok(added.is('.ui-state-hover'), 'should add mouseover handler to added tab'); 55 added.simulate('mouseout'); 56 var other = $('li:first', el).simulate('mouseover'); 57 ok(other.is('.ui-state-hover'), 'should not remove mouseover handler from existing tab'); 58 other.simulate('mouseout'); 59 60 equals($('a', added).attr('href'), '#new', 'should not expand href to full url of current page'); 61 62 ok(false, "missing test - untested code is broken code."); 63 }); 64 65 test('remove', function() { 66 expect(4); 67 68 el = $('#tabs1').tabs(); 69 70 el.tabs('remove', 0); 71 equals(el.tabs('length'), 2, 'remove tab'); 72 equals($('li a[href$="fragment-1"]', el).length, 0, 'remove associated list item'); 73 equals($('#fragment-1').length, 0, 'remove associated panel'); 74 75 // TODO delete tab -> focus tab to right 76 // TODO delete last tab -> focus tab to left 77 78 el.tabs('select', 1); 79 el.tabs('remove', 1); 80 equals(el.data('selected.tabs'), 0, 'update selected property'); 81 }); 82 83 test('select', function() { 84 expect(9); 85 86 el = $('#tabs1').tabs(); 87 88 el.tabs('select', 1); 89 equals(el.data('selected.tabs'), 1, 'should select tab'); 90 91 el.tabs('destroy'); 92 el.tabs({ collapsible: true }); 93 el.tabs('select', 0); 94 equals(el.data('selected.tabs'), -1, 'should collapse tab passing in the already selected tab'); 95 96 el.tabs('destroy'); 97 el.tabs({ collapsible: true }); 98 el.tabs('select', -1); 99 equals(el.data('selected.tabs'), -1, 'should collapse tab passing in -1'); 100 101 el.tabs('destroy'); 102 el.tabs({ collapsible: true }); 103 el.tabs('select', null); 104 equals(el.data('selected.tabs'), -1, 'should collapse tab passing in null (deprecated)'); 105 el.tabs('select', null); 106 equals(el.data('selected.tabs'), -1, 'should not select tab passing in null a second time (deprecated)'); 107 108 el.tabs('destroy'); 109 el.tabs(); 110 el.tabs('select', 0); 111 equals(el.data('selected.tabs'), 0, 'should not collapse tab if collapsible is not set to true'); 112 el.tabs('select', -1); 113 equals(el.data('selected.tabs'), 0, 'should not collapse tab if collapsible is not set to true'); 114 el.tabs('select', null); 115 equals(el.data('selected.tabs'), 0, 'should not collapse tab if collapsible is not set to true'); 116 117 el.tabs('select', '#fragment-2'); 118 equals(el.data('selected.tabs'), 1, 'should select tab by id'); 119 }); 120 121 test('load', function() { 122 ok(false, "missing test - untested code is broken code."); 123 }); 124 125 test('url', function() { 126 ok(false, "missing test - untested code is broken code."); 127 }); 128 129 test('length', function() { 130 expect(1); 131 132 el = $('#tabs1').tabs(); 133 equals(el.tabs('length'), $('ul a', el).length, ' should return length'); 134 }); 135 136 test('rotate', function() { 137 ok(false, "missing test - untested code is broken code."); 138 }); 139 140 })(jQuery);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |