Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paragon
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
OpenEdx
paragon
Commits
0c5cea6e
Commit
0c5cea6e
authored
Oct 03, 2017
by
Michael Roytman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add additional testing coverage for Dropdown
parent
68ce41ec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
3 deletions
+33
-3
src/Dropdown/Dropdown.test.jsx
+33
-3
No files found.
src/Dropdown/Dropdown.test.jsx
View file @
0c5cea6e
...
...
@@ -149,6 +149,16 @@ describe('<Dropdown />', () => {
});
});
describe
(
'invalid key in open menu'
,
()
=>
{
it
(
'test'
,
()
=>
{
menuOpen
(
true
,
wrapper
);
expect
(
wrapper
.
find
(
'a'
).
at
(
0
).
matchesElement
(
document
.
activeElement
)).
toEqual
(
true
);
wrapper
.
find
(
'a'
).
at
(
0
).
simulate
(
'keyDown'
,
{
key
:
'q'
});
menuOpen
(
true
,
wrapper
);
expect
(
wrapper
.
find
(
'a'
).
at
(
0
).
matchesElement
(
document
.
activeElement
)).
toEqual
(
true
);
});
});
it
(
'first menu item after looping through'
,
()
=>
{
wrapper
.
find
(
'a'
).
at
(
0
).
simulate
(
'keyDown'
,
{
key
:
triggerKeys
.
NAVIGATE_DOWN
[
0
]
});
wrapper
.
find
(
'a'
).
at
(
1
).
simulate
(
'keyDown'
,
{
key
:
triggerKeys
.
NAVIGATE_DOWN
[
0
]
});
...
...
@@ -156,9 +166,29 @@ describe('<Dropdown />', () => {
expect
(
wrapper
.
find
(
'a'
).
at
(
0
).
matchesElement
(
document
.
activeElement
)).
toEqual
(
true
);
});
it
(
'toggle on close'
,
()
=>
{
wrapper
.
find
(
'a'
).
at
(
0
).
simulate
(
'keyDown'
,
{
key
:
triggerKeys
.
CLOSE_MENU
[
0
]
});
expect
(
wrapper
.
find
(
'[type="button"]'
).
matchesElement
(
document
.
activeElement
)).
toEqual
(
true
);
describe
(
'toggle'
,
()
=>
{
it
(
'toggle on close'
,
()
=>
{
wrapper
.
find
(
'a'
).
at
(
0
).
simulate
(
'keyDown'
,
{
key
:
triggerKeys
.
CLOSE_MENU
[
0
]
});
expect
(
wrapper
.
find
(
'[type="button"]'
).
matchesElement
(
document
.
activeElement
)).
toEqual
(
true
);
});
it
(
'does not toggle with invalid key'
,
()
=>
{
wrapper
=
mount
(
<
Dropdown
{
...
props
}
/>,
);
menuOpen
(
false
,
wrapper
);
// open and close button to get focus on button
wrapper
.
find
(
'[type="button"]'
).
simulate
(
'click'
);
wrapper
.
find
(
'[type="button"]'
).
simulate
(
'click'
);
expect
(
wrapper
.
find
(
'[type="button"]'
).
matchesElement
(
document
.
activeElement
)).
toEqual
(
true
);
wrapper
.
find
(
'[type="button"]'
).
simulate
(
'keyDown'
,
{
key
:
'q'
});
menuOpen
(
false
,
wrapper
);
expect
(
wrapper
.
find
(
'[type="button"]'
).
matchesElement
(
document
.
activeElement
)).
toEqual
(
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