Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
8f19128d
Commit
8f19128d
authored
Feb 01, 2016
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unit tests so they are testing aria-expanded.
parent
c325fc63
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
29 deletions
+17
-29
lms/static/js/fixtures/accordion.html
+4
-4
lms/static/js/spec/navigation_spec.js
+13
-25
No files found.
lms/static/js/fixtures/accordion.html
View file @
8f19128d
<div
class=
"course-wrapper"
>
<div
class=
"accordion"
>
<a
href=
"accordion-menu-1"
role=
"button"
class=
"button-chapter chapter is-open"
aria-controls=
"accordion-menu-1"
>
<a
href=
"accordion-menu-1"
role=
"button"
class=
"button-chapter chapter is-open"
aria-controls=
"accordion-menu-1"
aria-expanded=
"true"
>
<span
class=
"group-heading active"
>
1 Introduction Chapter
</span>
</a>
<div
class=
"chapter-content-container is-open"
id=
"accordion-menu-1"
tabindex=
"-1"
aria-expanded=
"true"
>
<div
class=
"chapter-content-container is-open"
id=
"accordion-menu-1"
tabindex=
"-1"
>
<div
class=
"chapter-menu is-open"
>
<div
class=
"menu-item"
>
<a
href=
"#"
>
...
...
@@ -25,12 +25,12 @@
</a>
</div>
</div>
<a
href=
"accordion-menu-2"
role=
"button"
class=
"button-chapter chapter"
aria-controls=
"accordion-menu-2"
>
<a
href=
"accordion-menu-2"
role=
"button"
class=
"button-chapter chapter"
aria-controls=
"accordion-menu-2"
aria-expanded=
"false"
>
<span
class=
"group-heading"
>
2 Another Chapter
</span>
</a>
<div
class=
"chapter-content-container"
id=
"accordion-menu-2"
tabindex=
"-1"
aria-expanded=
"false"
>
<div
class=
"chapter-content-container"
id=
"accordion-menu-2"
tabindex=
"-1"
>
<div
class=
"chapter-menu"
>
<div
class=
"menu-item"
>
<a
href=
"#"
>
...
...
lms/static/js/spec/navigation_spec.js
View file @
8f19128d
...
...
@@ -2,7 +2,7 @@ define(['jquery', 'js/utils/navigation'], function($) {
'use strict'
;
describe
(
'Course Navigation Accordion'
,
function
()
{
var
accordion
,
button
,
heading
,
chapterContent
,
chapterMenu
;
var
accordion
,
chapterMenu
;
function
keyPressEvent
(
key
)
{
return
$
.
Event
(
'keydown'
,
{
which
:
key
});
...
...
@@ -12,10 +12,7 @@ define(['jquery', 'js/utils/navigation'], function($) {
loadFixtures
(
'js/fixtures/accordion.html'
);
accordion
=
$
(
'.accordion'
);
button
=
accordion
.
children
(
'.button-chapter'
);
heading
=
button
.
children
(
'.group-heading'
);
chapterContent
=
accordion
.
children
(
'.chapter-content-container'
);
chapterMenu
=
chapterContent
.
children
(
'.chapter-menu'
);
chapterMenu
=
accordion
.
children
(
'.chapter-content-container'
).
children
(
'.chapter-menu'
);
this
.
KEY
=
$
.
ui
.
keyCode
;
spyOn
(
$
.
fn
,
'focus'
).
andCallThrough
();
...
...
@@ -31,13 +28,8 @@ define(['jquery', 'js/utils/navigation'], function($) {
});
it
(
'ensures aria attributes are present'
,
function
()
{
expect
(
accordion
.
find
(
'.chapter-content-container'
).
first
()).
toHaveAttr
({
'aria-expanded'
:
'true'
});
expect
(
accordion
.
find
(
'.chapter-content-container'
).
last
()).
toHaveAttr
({
'aria-expanded'
:
'false'
});
expect
(
accordion
.
find
(
'.button-chapter'
).
first
()).
toHaveAttr
(
'aria-expanded'
,
'true'
);
expect
(
accordion
.
find
(
'.button-chapter'
).
last
()).
toHaveAttr
(
'aria-expanded'
,
'false'
);
});
it
(
'ensures only one active item'
,
function
()
{
...
...
@@ -58,19 +50,17 @@ define(['jquery', 'js/utils/navigation'], function($) {
});
it
(
'ensure proper aria and attrs'
,
function
()
{
expect
(
accordion
.
find
(
'.chapter-content-container'
).
first
()).
toHaveAttr
({
'aria-expanded'
:
'false'
});
expect
(
accordion
.
find
(
'.chapter-content-container'
).
last
()).
toHaveAttr
({
'aria-expanded'
:
'true'
});
accordion
.
find
(
'.button-chapter'
).
last
().
trigger
(
'click'
);
expect
(
accordion
.
find
(
'.button-chapter'
).
first
()).
toHaveAttr
(
'aria-expanded'
,
'false'
);
expect
(
accordion
.
find
(
'.button-chapter'
).
last
()).
toHaveAttr
(
'aria-expanded'
,
'true'
);
});
});
describe
(
'open section with spacebar'
,
function
()
{
it
(
'ensures new section is opened and previous section is closed'
,
function
()
{
accordion
.
find
(
'.button-chapter'
).
last
().
focus
().
trigger
(
keyPressEvent
(
this
.
KEY
.
SPACE
));
// Spacebar
accordion
.
find
(
'.button-chapter'
).
last
().
focus
().
trigger
(
keyPressEvent
(
this
.
KEY
.
SPACE
));
expect
(
accordion
.
find
(
'.chapter-content-container'
).
first
()).
not
.
toHaveClass
(
'is-open'
);
expect
(
accordion
.
find
(
'.chapter-content-container'
).
last
()).
toHaveClass
(
'is-open'
);
...
...
@@ -80,12 +70,10 @@ define(['jquery', 'js/utils/navigation'], function($) {
});
it
(
'ensure proper aria and attrs'
,
function
()
{
expect
(
accordion
.
find
(
'.chapter-content-container'
).
first
()).
toHaveAttr
({
'aria-expanded'
:
'false'
});
expect
(
accordion
.
find
(
'.chapter-content-container'
).
last
()).
toHaveAttr
({
'aria-expanded'
:
'true'
});
accordion
.
find
(
'.button-chapter'
).
last
().
focus
().
trigger
(
keyPressEvent
(
this
.
KEY
.
SPACE
));
expect
(
accordion
.
find
(
'.button-chapter'
).
first
()).
toHaveAttr
(
'aria-expanded'
,
'false'
);
expect
(
accordion
.
find
(
'.button-chapter'
).
last
()).
toHaveAttr
(
'aria-expanded'
,
'true'
);
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment