Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
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
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
1f449c9b
Commit
1f449c9b
authored
Mar 18, 2020
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve shortcut tests
- Add tests for multiple modifier keys - Add assertion to a test without any
parent
fcf15d07
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
7 deletions
+26
-7
shortcut-test.js
src/shared/test/shortcut-test.js
+26
-7
No files found.
src/shared/test/shortcut-test.js
View file @
1f449c9b
...
...
@@ -16,10 +16,23 @@ function createEvent(key, { ctrl, alt, shift, meta } = {}) {
describe
(
'shared/shortcut'
,
()
=>
{
describe
(
'matchShortcut'
,
()
=>
{
[
// Single modifier.
{
shortcut
:
'ctrl+a'
,
event
:
createEvent
(
'a'
,
{
ctrl
:
true
})
},
{
shortcut
:
'meta+a'
,
event
:
createEvent
(
'a'
,
{
meta
:
true
})
},
{
shortcut
:
'shift+a'
,
event
:
createEvent
(
'a'
,
{
shift
:
true
})
},
{
shortcut
:
'alt+a'
,
event
:
createEvent
(
'a'
,
{
alt
:
true
})
},
// Multiple modifiers.
{
shortcut
:
'ctrl+shift+a'
,
event
:
createEvent
(
'a'
,
{
ctrl
:
true
,
shift
:
true
}),
},
{
shortcut
:
'alt+meta+a'
,
event
:
createEvent
(
'a'
,
{
alt
:
true
,
meta
:
true
}),
},
// No modifier.
{
shortcut
:
'a'
,
event
:
createEvent
(
'a'
)
},
].
forEach
(({
shortcut
,
event
})
=>
{
it
(
'should match if modifiers match'
,
()
=>
{
...
...
@@ -27,13 +40,17 @@ describe('shared/shortcut', () => {
});
});
[{
shortcut
:
'ctrl+a'
,
event
:
createEvent
(
'a'
,
{
ctrl
:
false
})
}].
forEach
(
({
shortcut
,
event
})
=>
{
[
{
shortcut
:
'ctrl+a'
,
event
:
createEvent
(
'a'
,
{
ctrl
:
false
})
},
{
shortcut
:
'ctrl+shift+a'
,
event
:
createEvent
(
'a'
,
{
ctrl
:
true
,
shift
:
false
}),
},
].
forEach
(({
shortcut
,
event
})
=>
{
it
(
'should not match if modifiers do not match'
,
()
=>
{
assert
.
isFalse
(
matchShortcut
(
event
,
shortcut
));
});
}
);
});
[
{
shortcut
:
'a'
,
event
:
createEvent
(
'a'
)
},
...
...
@@ -169,6 +186,8 @@ describe('shared/shortcut', () => {
});
triggerShortcut
({
key
:
'a'
});
assert
.
notCalled
(
onClick
);
});
});
});
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