Skip to content

Commit

Permalink
Tests: Enable QUnit.config.requireExpects.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgonzalez committed Jun 27, 2012
1 parent 9b6c1c5 commit 5ae668f
Show file tree
Hide file tree
Showing 23 changed files with 133 additions and 2 deletions.
6 changes: 6 additions & 0 deletions tests/unit/button/button_core.js
Expand Up @@ -8,6 +8,7 @@
module("button: core");

test("checkbox", function() {
expect( 4 );
var input = $("#check"),
label = $("label[for=check]");
ok( input.is(":visible") );
Expand All @@ -18,6 +19,7 @@ test("checkbox", function() {
});

test("radios", function() {
expect( 4 );
var inputs = $("#radio0 input"),
labels = $("#radio0 label");
ok( inputs.is(":visible") );
Expand All @@ -34,6 +36,7 @@ function assert(noForm, form1, form2) {
}

test("radio groups", function() {
expect( 12 );
$("input[type=radio]").button();
assert(":eq(0)", ":eq(1)", ":eq(2)");

Expand All @@ -51,13 +54,15 @@ test("radio groups", function() {
});

test("input type submit, don't create child elements", function() {
expect( 2 );
var input = $("#submit");
deepEqual( input.children().length, 0 );
input.button();
deepEqual( input.children().length, 0 );
});

test("buttonset", function() {
expect( 6 );
var set = $("#radio1").buttonset();
ok( set.is(".ui-buttonset") );
deepEqual( set.children(".ui-button").length, 3 );
Expand All @@ -68,6 +73,7 @@ test("buttonset", function() {
});

test("buttonset (rtl)", function() {
expect( 6 );
var set,
parent = $("#radio1").parent();
// Set to rtl
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/button/button_options.js
Expand Up @@ -6,6 +6,7 @@
module("button: options");

test("disabled, explicit value", function() {
expect( 4 );
$("#radio01").button({ disabled: false });
deepEqual(false, $("#radio01").button("option", "disabled"),
"disabled option set to false");
Expand All @@ -18,6 +19,7 @@ test("disabled, explicit value", function() {
});

test("disabled, null", function() {
expect( 4 );
$("#radio01").button({ disabled: null });
deepEqual(false, $("#radio01").button("option", "disabled"),
"disabled option set to false");
Expand All @@ -30,6 +32,7 @@ test("disabled, null", function() {
});

test("text false without icon", function() {
expect( 1 );
$("#button").button({
text: false
});
Expand All @@ -39,6 +42,7 @@ test("text false without icon", function() {
});

test("text false with icon", function() {
expect( 1 );
$("#button").button({
text: false,
icons: {
Expand All @@ -51,6 +55,7 @@ test("text false with icon", function() {
});

test("label, default", function() {
expect( 2 );
$("#button").button();
deepEqual( $("#button").text(), "Label" );
deepEqual( $( "#button").button( "option", "label" ), "Label" );
Expand All @@ -59,6 +64,7 @@ test("label, default", function() {
});

test("label", function() {
expect( 2 );
$("#button").button({
label: "xxx"
});
Expand All @@ -69,11 +75,13 @@ test("label", function() {
});

test("label default with input type submit", function() {
expect( 2 );
deepEqual( $("#submit").button().val(), "Label" );
deepEqual( $("#submit").button( "option", "label" ), "Label" );
});

test("label with input type submit", function() {
expect( 2 );
var label = $("#submit").button({
label: "xxx"
}).val();
Expand All @@ -82,6 +90,7 @@ test("label with input type submit", function() {
});

test("icons", function() {
expect( 1 );
$("#button").button({
text: false,
icons: {
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/button/button_tickets.js
Expand Up @@ -6,13 +6,15 @@
module( "button: tickets" );

test( "#5946 - buttonset should ignore buttons that are not :visible", function() {
expect( 2 );
$( "#radio01" ).next().andSelf().hide();
var set = $( "#radio0" ).buttonset({ items: "input[type=radio]:visible" });
ok( set.find( "label:eq(0)" ).is( ":not(.ui-button):not(.ui-corner-left)" ) );
ok( set.find( "label:eq(1)" ).is( ".ui-button.ui-corner-left" ) );
});

test( "#6262 - buttonset not applying ui-corner to invisible elements", function() {
expect( 3 );
$( "#radio0" ).hide();
var set = $( "#radio0" ).buttonset();
ok( set.find( "label:eq(0)" ).is( ".ui-button.ui-corner-left" ) );
Expand All @@ -21,6 +23,7 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function
});

test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
expect( 2 );
var check = $( "#check" ).button(),
label = $( "label[for='check']" );
ok( !label.is( ".ui-state-focus" ) );
Expand All @@ -29,6 +32,7 @@ test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard
});

test( "#7092 - button creation that requires a matching label does not find label in all cases", function() {
expect( 5 );
var group = $( "<span><label for='t7092a'></label><input type='checkbox' id='t7092a'></span>" );
group.find( "input[type=checkbox]" ).button();
ok( group.find( "label" ).is( ".ui-button" ) );
Expand All @@ -51,6 +55,7 @@ test( "#7092 - button creation that requires a matching label does not find labe
});

test( "#7534 - Button label selector works for ids with \":\"", function() {
expect( 1 );
var group = $( "<span><input type='checkbox' id='check:7534'><label for='check:7534'>Label</label></span>" );
group.find( "input" ).button();
ok( group.find( "label" ).is( ".ui-button" ), "Found an id with a :" );
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/core/core.js
Expand Up @@ -28,6 +28,7 @@ asyncTest( "focus", function() {
});

test( "zIndex", function() {
expect( 7 );
var el = $( "#zIndexAutoWithParent" ),
parent = el.parent();
equal( el.zIndex(), 100, "zIndex traverses up to find value" );
Expand All @@ -46,6 +47,7 @@ test( "zIndex", function() {
});

test( "innerWidth - getter", function() {
expect( 2 );
var el = $( "#dimensions" );

equal( el.innerWidth(), 122, "getter passthru" );
Expand All @@ -54,6 +56,7 @@ test( "innerWidth - getter", function() {
});

test( "innerWidth - setter", function() {
expect( 2 );
var el = $( "#dimensions" );

el.innerWidth( 120 );
Expand All @@ -64,6 +67,7 @@ test( "innerWidth - setter", function() {
});

test( "innerHeight - getter", function() {
expect( 2 );
var el = $( "#dimensions" );

equal( el.innerHeight(), 70, "getter passthru" );
Expand All @@ -72,6 +76,7 @@ test( "innerHeight - getter", function() {
});

test( "innerHeight - setter", function() {
expect( 2 );
var el = $( "#dimensions" );

el.innerHeight( 60 );
Expand All @@ -82,6 +87,7 @@ test( "innerHeight - setter", function() {
});

test( "outerWidth - getter", function() {
expect( 2 );
var el = $( "#dimensions" );

equal( el.outerWidth(), 140, "getter passthru" );
Expand All @@ -90,6 +96,7 @@ test( "outerWidth - getter", function() {
});

test( "outerWidth - setter", function() {
expect( 2 );
var el = $( "#dimensions" );

el.outerWidth( 130 );
Expand All @@ -100,6 +107,7 @@ test( "outerWidth - setter", function() {
});

test( "outerWidth(true) - getter", function() {
expect( 2 );
var el = $( "#dimensions" );

equal( el.outerWidth(true), 154, "getter passthru w/ margin" );
Expand All @@ -108,6 +116,7 @@ test( "outerWidth(true) - getter", function() {
});

test( "outerWidth(true) - setter", function() {
expect( 2 );
var el = $( "#dimensions" );

el.outerWidth( 130, true );
Expand All @@ -118,6 +127,7 @@ test( "outerWidth(true) - setter", function() {
});

test( "outerHeight - getter", function() {
expect( 2 );
var el = $( "#dimensions" );

equal( el.outerHeight(), 86, "getter passthru" );
Expand All @@ -126,6 +136,7 @@ test( "outerHeight - getter", function() {
});

test( "outerHeight - setter", function() {
expect( 2 );
var el = $( "#dimensions" );

el.outerHeight( 80 );
Expand All @@ -136,6 +147,7 @@ test( "outerHeight - setter", function() {
});

test( "outerHeight(true) - getter", function() {
expect( 2 );
var el = $( "#dimensions" );

equal( el.outerHeight(true), 98, "getter passthru w/ margin" );
Expand All @@ -144,6 +156,7 @@ test( "outerHeight(true) - getter", function() {
});

test( "outerHeight(true) - setter", function() {
expect( 2 );
var el = $( "#dimensions" );

el.outerHeight( 90, true );
Expand All @@ -154,6 +167,7 @@ test( "outerHeight(true) - setter", function() {
});

test( "uniqueId / removeUniqueId", function() {
expect( 3 );
var el = $( "img" ).eq( 0 );

// support: jQuery <1.6.2
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/core/selector.js
Expand Up @@ -150,6 +150,8 @@ test("focusable - not natively focusable with various tabindex", function() {
});

test("focusable - area elements", function() {
expect( 3 );

isFocusable('#areaCoordsHref', 'coords and href');
isFocusable('#areaNoCoordsHref', 'href but no coords');
isNotFocusable('#areaNoImg', 'not associated with an image');
Expand Down Expand Up @@ -227,6 +229,8 @@ test("tabbable - not natively tabbable with various tabindex", function() {
});

test("tabbable - area elements", function() {
expect( 3 );

isTabbable('#areaCoordsHref', 'coords and href');
isTabbable('#areaNoCoordsHref', 'href but no coords');
isNotTabbable('#areaNoImg', 'not associated with an image');
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/datepicker/datepicker_core.js
Expand Up @@ -43,16 +43,19 @@ var PROP_NAME = 'datepicker';
module("datepicker: core");

test( "widget method - empty collection", function() {
expect( 1 );
$( "#nonExist" ).datepicker(); // should create nothing
ok( !$( "#ui-datepicker-div" ).length, "Non init on empty collection" );
});

test("widget method", function() {
expect( 1 );
var actual = $("#inp").datepicker().datepicker("widget")[0];
deepEqual($("body > #ui-datepicker-div:last-child")[0], actual);
});

test('baseStructure', function() {
expect( 59 );
var header, title, table, thead, week, panel, inl, child,
inp = init('#inp').focus(),
dp = $('#ui-datepicker-div'),
Expand Down Expand Up @@ -176,6 +179,7 @@ test('baseStructure', function() {
});

test('customStructure', function() {
expect( 20 );
var iframe, header, panel, title, thead,
dp = $('#ui-datepicker-div'),
// Check right-to-left localisation
Expand Down Expand Up @@ -233,6 +237,7 @@ test('customStructure', function() {
});

test('keystrokes', function() {
expect( 26 );
var inp = init('#inp'),
date = new Date();
inp.val('').datepicker('show').
Expand Down Expand Up @@ -367,6 +372,7 @@ test('keystrokes', function() {
});

test('mouse', function() {
expect( 15 );
var inl,
inp = init('#inp'),
dp = $('#ui-datepicker-div'),
Expand Down
1 change: 1 addition & 0 deletions tests/unit/datepicker/datepicker_events.js
Expand Up @@ -22,6 +22,7 @@ function callback2(year, month, inst) {
}

test('events', function() {
expect( 26 );
var dateStr, newMonthYear, inp2,
inp = init('#inp', {onSelect: callback}),
date = new Date();
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/datepicker/datepicker_methods.js
Expand Up @@ -6,6 +6,7 @@
module("datepicker: methods");

test('destroy', function() {
expect( 33 );
var inl,
inp = init('#inp');
ok(inp.is('.hasDatepicker'), 'Default - marker class set');
Expand Down Expand Up @@ -63,6 +64,7 @@ test('destroy', function() {
});

test('enableDisable', function() {
expect( 33 );
var inl, dp,
inp = init('#inp');
ok(!inp.datepicker('isDisabled'), 'Enable/disable - initially marked as enabled');
Expand Down

0 comments on commit 5ae668f

Please sign in to comment.