Skip to content

Tests: Replace resource loader with AMD #1335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
bb47aad
Tests: Replace resource loader with AMD
rxaviers Dec 12, 2013
78801c6
(fix) Tests: Replace resource loader with AMD
rxaviers Dec 12, 2013
df62114
(fix) Tests: Replace resource loader with AMD
rxaviers Dec 12, 2013
3afb4d0
(fix) Tests: Replace resource loader with AMD
rxaviers Dec 12, 2013
5ca958a
(fix) Tests: Replace resource loader with AMD
rxaviers Dec 12, 2013
2834651
(fix) Tests: Replace resource loader with AMD
rxaviers Dec 12, 2013
8ac5a49
Revert "(fix) Tests: Replace resource loader with AMD"
rxaviers Sep 3, 2014
b2d649f
(fix) Tests: Replace resource loader with AMD
rxaviers Sep 3, 2014
cf94731
(fix) Tests: Replace resource loader with AMD
rxaviers Sep 3, 2014
21bbc2e
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 14, 2014
337b775
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 14, 2014
cdfc27e
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 14, 2014
9c3d95c
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 14, 2014
bc593d3
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 19, 2014
7655302
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 19, 2014
64b786f
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 19, 2014
b810fc3
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 19, 2014
757164d
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 19, 2014
8281580
(fix) Tests: Replace resource loader with AMD
rxaviers Nov 19, 2014
f44cb7c
(fix) Tests: Replace resource loader with AMD
rxaviers Dec 10, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
(fix) Tests: Replace resource loader with AMD
  • Loading branch information
rxaviers committed Nov 14, 2014
commit 337b775471b362b237fb490ebaa872fb8456861a
21 changes: 8 additions & 13 deletions tests/unit/accordion/accordion.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,16 @@ <h2><a href="?p=1.1.3">Drums</a></h2>
<script src="../../../external/qunit/qunit.js"></script>
<script src="../swarminject.js"></script>
<script src="../helper/jquery.js"></script>
<script src="../helper/require.js"></script>
<script>
QUnit.config.autostart = false;
require.config({
paths: {
"helper": "../helper",
"jquery": window.helper.jqueryUrl(),
"jquery.simulate": "../../../external/jquery-simulate/jquery.simulate",
"jshint": "../../../external/jshint/jshint",
"ui": "../../../ui"
},
shim: {
"jquery.simulate": [ "jquery" ]
}
});
require([ "./accordion" ], function() {
require_series([
"./accordion_common",
"./accordion_core",
"./accordion_events" ,
"./accordion_methods",
"./accordion_options"
], function() {
QUnit.start();
});
</script>
Expand Down
15 changes: 0 additions & 15 deletions tests/unit/accordion/accordion.js

This file was deleted.

4 changes: 0 additions & 4 deletions tests/unit/accordion/accordion_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ define([
"ui/accordion"
], function( testHelper ) {

return function() {

testHelper.commonWidgetTests( "accordion", {
defaults: {
active: 0,
Expand All @@ -26,6 +24,4 @@ testHelper.commonWidgetTests( "accordion", {
}
});

};

});
216 changes: 106 additions & 110 deletions tests/unit/accordion/accordion_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,122 +5,118 @@ define([
"jquery.simulate"
], function( $, accordionTestHelper ) {

return function() {

var setupTeardown = accordionTestHelper.setupTeardown,
state = accordionTestHelper.state;

module( "accordion: core", setupTeardown() );

$.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) {
test( "markup structure: " + type, function() {
expect( 4 );
var element = $( selector ).accordion();
ok( element.hasClass( "ui-accordion" ), "main element is .ui-accordion" );
equal( element.find( ".ui-accordion-header" ).length, 3,
".ui-accordion-header elements exist, correct number" );
equal( element.find( ".ui-accordion-content" ).length, 3,
".ui-accordion-content elements exist, correct number" );
deepEqual( element.find( ".ui-accordion-header" ).next().get(),
element.find( ".ui-accordion-content" ).get(),
"content panels come immediately after headers" );
});
});

test( "handle click on header-descendant", function() {
expect( 1 );
var element = $( "#navigation" ).accordion();
$( "#navigation h2:eq(1) a" ).click();
state( element, 0, 1, 0 );
var setupTeardown = accordionTestHelper.setupTeardown,
state = accordionTestHelper.state;

module( "accordion: core", setupTeardown() );

$.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) {
test( "markup structure: " + type, function() {
expect( 4 );
var element = $( selector ).accordion();
ok( element.hasClass( "ui-accordion" ), "main element is .ui-accordion" );
equal( element.find( ".ui-accordion-header" ).length, 3,
".ui-accordion-header elements exist, correct number" );
equal( element.find( ".ui-accordion-content" ).length, 3,
".ui-accordion-content elements exist, correct number" );
deepEqual( element.find( ".ui-accordion-header" ).next().get(),
element.find( ".ui-accordion-content" ).get(),
"content panels come immediately after headers" );
});
});

test( "accessibility", function () {
expect( 37 );
var element = $( "#list1" ).accordion({
active: 1
}),
headers = element.find( ".ui-accordion-header" );

equal( element.attr( "role" ), "tablist", "element role" );
headers.each(function( i ) {
var header = headers.eq( i ),
panel = header.next();
equal( header.attr( "role" ), "tab", "header " + i + " role" );
equal( header.attr( "aria-controls" ), panel.attr( "id" ), "header " + i + " aria-controls" );
equal( panel.attr( "role" ), "tabpanel", "panel " + i + " role" );
equal( panel.attr( "aria-labelledby" ), header.attr( "id" ), "panel " + i + " aria-labelledby" );
});

equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" );
equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
test( "handle click on header-descendant", function() {
expect( 1 );
var element = $( "#navigation" ).accordion();
$( "#navigation h2:eq(1) a" ).click();
state( element, 0, 1, 0 );
});

element.accordion( "option", "active", 0 );
equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
equal( headers.eq( 0 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" );
equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
test( "accessibility", function () {
expect( 37 );
var element = $( "#list1" ).accordion({
active: 1
}),
headers = element.find( ".ui-accordion-header" );

equal( element.attr( "role" ), "tablist", "element role" );
headers.each(function( i ) {
var header = headers.eq( i ),
panel = header.next();
equal( header.attr( "role" ), "tab", "header " + i + " role" );
equal( header.attr( "aria-controls" ), panel.attr( "id" ), "header " + i + " aria-controls" );
equal( panel.attr( "role" ), "tabpanel", "panel " + i + " role" );
equal( panel.attr( "aria-labelledby" ), header.attr( "id" ), "panel " + i + " aria-labelledby" );
});

asyncTest( "keyboard support", function() {
expect( 13 );
var element = $( "#list1" ).accordion(),
headers = element.find( ".ui-accordion-header" ),
anchor = headers.eq( 1 ).next().find( "a" ).eq( 0 ),
keyCode = $.ui.keyCode;
equal( headers.filter( ".ui-state-focus" ).length, 0, "no headers focused on init" );
headers.eq( 0 ).simulate( "focus" );
setTimeout(function() {
ok( headers.eq( 0 ).is( ".ui-state-focus" ), "first header has focus" );
headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.DOWN } );
ok( headers.eq( 1 ).is( ".ui-state-focus" ), "DOWN moves focus to next header" );
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.RIGHT } );
ok( headers.eq( 2 ).is( ".ui-state-focus" ), "RIGHT moves focus to next header" );
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.DOWN } );
ok( headers.eq( 0 ).is( ".ui-state-focus" ), "DOWN wraps focus to first header" );

headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.UP } );
ok( headers.eq( 2 ).is( ".ui-state-focus" ), "UP wraps focus to last header" );
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.LEFT } );
ok( headers.eq( 1 ).is( ".ui-state-focus" ), "LEFT moves focus to previous header" );

headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.HOME } );
ok( headers.eq( 0 ).is( ".ui-state-focus" ), "HOME moves focus to first header" );
headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.END } );
ok( headers.eq( 2 ).is( ".ui-state-focus" ), "END moves focus to last header" );

headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.ENTER } );
equal( element.accordion( "option", "active" ) , 2, "ENTER activates panel" );
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.SPACE } );
equal( element.accordion( "option", "active" ), 1, "SPACE activates panel" );
equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" );
equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );

element.accordion( "option", "active", 0 );
equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
equal( headers.eq( 0 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" );
equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
});

anchor.simulate( "focus" );
setTimeout(function() {
ok( !headers.eq( 1 ).is( ".ui-state-focus" ), "header loses focus when focusing inside the panel" );
anchor.simulate( "keydown", { keyCode: keyCode.UP, ctrlKey: true } );
ok( headers.eq( 1 ).is( ".ui-state-focus" ), "CTRL+UP moves focus to header" );
start();
}, 1 );
asyncTest( "keyboard support", function() {
expect( 13 );
var element = $( "#list1" ).accordion(),
headers = element.find( ".ui-accordion-header" ),
anchor = headers.eq( 1 ).next().find( "a" ).eq( 0 ),
keyCode = $.ui.keyCode;
equal( headers.filter( ".ui-state-focus" ).length, 0, "no headers focused on init" );
headers.eq( 0 ).simulate( "focus" );
setTimeout(function() {
ok( headers.eq( 0 ).is( ".ui-state-focus" ), "first header has focus" );
headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.DOWN } );
ok( headers.eq( 1 ).is( ".ui-state-focus" ), "DOWN moves focus to next header" );
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.RIGHT } );
ok( headers.eq( 2 ).is( ".ui-state-focus" ), "RIGHT moves focus to next header" );
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.DOWN } );
ok( headers.eq( 0 ).is( ".ui-state-focus" ), "DOWN wraps focus to first header" );

headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.UP } );
ok( headers.eq( 2 ).is( ".ui-state-focus" ), "UP wraps focus to last header" );
headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.LEFT } );
ok( headers.eq( 1 ).is( ".ui-state-focus" ), "LEFT moves focus to previous header" );

headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.HOME } );
ok( headers.eq( 0 ).is( ".ui-state-focus" ), "HOME moves focus to first header" );
headers.eq( 0 ).simulate( "keydown", { keyCode: keyCode.END } );
ok( headers.eq( 2 ).is( ".ui-state-focus" ), "END moves focus to last header" );

headers.eq( 2 ).simulate( "keydown", { keyCode: keyCode.ENTER } );
equal( element.accordion( "option", "active" ) , 2, "ENTER activates panel" );
headers.eq( 1 ).simulate( "keydown", { keyCode: keyCode.SPACE } );
equal( element.accordion( "option", "active" ), 1, "SPACE activates panel" );

anchor.simulate( "focus" );
setTimeout(function() {
ok( !headers.eq( 1 ).is( ".ui-state-focus" ), "header loses focus when focusing inside the panel" );
anchor.simulate( "keydown", { keyCode: keyCode.UP, ctrlKey: true } );
ok( headers.eq( 1 ).is( ".ui-state-focus" ), "CTRL+UP moves focus to header" );
start();
}, 1 );
});

};
}, 1 );
});

});
Loading