Skip to content
Permalink
Browse files

UI Tabs: fixed init tests, simplified destroy tests

  • Loading branch information...
Klaus Hartl
Klaus Hartl committed Jan 18, 2009
1 parent 941f6fe commit f0aa486bd6f1a5cec632ec4ccf97c80c48933da7
Showing with 14 additions and 25 deletions.
  1. +14 −25 tests/unit/tabs/tabs.js
@@ -38,42 +38,31 @@ module('tabs');
test('init', function() {
expect(9);

var el = $('#tabs1').tabs(); // new markup requires to tabify wrapper again...
ok(true, '.tabs() called on element');

el.tabs('destroy').tabs({ selected: 1 });
var el = $('#tabs1').tabs();

ok(true, '.tabs() called on element');
ok( el.is('.ui-tabs.ui-widget.ui-widget-content.ui-corner-all'), 'attach classes to container');
ok( $('ul', el).is('.ui-tabs-nav.ui-helper-reset.ui-helper-clearfix.ui-widget-header.ui-corner-all'), 'attach classes to list' );
ok( $('div:eq(0)', el).is('.ui-tabs-panel.ui-widget-content.ui-corner-bottom'), 'attach classes to panel' );
ok( $('li:eq(0)', el).is('.ui-state-default.ui-corner-top'), 'attach classes to inactive li');
ok( $('li:eq(1)', el).is('.ui-tabs-selected.ui-state-active.ui-corner-top'), 'attach classes to active li');
equals( el.data('selected.tabs'), 1, 'selected.tabs set' );
equals( $('li', el).index( $('li.ui-tabs-selected', el) ), 1, 'second tab active');
equals( $('div', el).index( $('div.ui-tabs-hide', '#tabs1') ), 0, 'first panel should be hidden' );
ok( $('li:eq(0)', el).is('.ui-tabs-selected.ui-state-active.ui-corner-top'), 'attach classes to active li');
ok( $('li:eq(1)', el).is('.ui-state-default.ui-corner-top'), 'attach classes to inactive li');
equals( el.data('selected.tabs'), 0, 'selected.tabs set' );
equals( $('li', el).index( $('li.ui-tabs-selected', el) ), 0, 'second tab active');
equals( $('div', el).index( $('div.ui-tabs-hide', '#tabs1') ), 1, 'second panel should be hidden' );

});

test('destroy', function() {
expect(14);
expect(5);

var el = $('#tabs1').tabs(); // new markup requires to tabify wrapper again...
var el = $('#tabs1').tabs();
el.tabs('destroy');

ok( el.is(':not(.ui-tabs)'), 'remove classes from container');
ok( el.is(':not(.ui-widget)'), 'remove classes from container');
ok( el.is(':not(.ui-widget-content)'), 'remove classes from container');
ok( el.is(':not(.ui-corner-all)'), 'remove classes from container');
ok( $('ul', el).is(':not(.ui-tabs-nav)'), 'remove classes from list' );
ok( $('ul', el).is(':not(.ui-helper-reset)'), 'remove classes from list' );
ok( $('ul', el).is(':not(.ui-helper-clearfix)'), 'remove classes from list' );
ok( $('ul', el).is(':not(.ui-widget-header)'), 'remove classes from list' );
ok( $('ul', el).is(':not(.ui-corner-all)'), 'remove classes from list' );
ok( $('li:eq(0)', el).is(':not(.ui-tabs-selected)'), 'remove classes from active li');
ok( $('li:eq(0)', el).is(':not(.ui-state-active)'), 'remove classes from active li');
ok( $('li:eq(0)', el).is(':not(.ui-corner-top)'), 'remove classes from active li');
ok( $('li:eq(1)', el).is(':not(.ui-state-default)'), 'remove classes from inactive li');
ok( $('li:eq(1)', el).is(':not(.ui-corner-top)'), 'remove classes from inactive li');
ok( el.is(':not(.ui-tabs, .ui-widget, .ui-widget-content, .ui-corner-all)'), 'remove classes from container');
ok( $('ul', el).is(':not(.ui-tabs-nav, .ui-helper-reset, .ui-helper-clearfix, .ui-widget-header, .ui-corner-all)'), 'remove classes from list' );
ok( $('div:eq(1)', el).is(':not(.ui-tabs-panel, .ui-widget-content, .ui-corner-bottom, .ui-tabs-hide)'), 'remove classes to panel' );
ok( $('li:eq(0)', el).is(':not(.ui-tabs-selected, .ui-state-active, .ui-corner-top)'), 'remove classes from active li');
ok( $('li:eq(1)', el).is(':not(.ui-state-default, .ui-corner-top)'), 'remove classes from inactive li');

});

0 comments on commit f0aa486

Please sign in to comment.
You can’t perform that action at this time.