Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
8e6fa255
Commit
8e6fa255
authored
Apr 18, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add JS specs for replyWithSelectedText
parent
ca5d0c82
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
519 additions
and
0 deletions
+519
-0
app/assets/javascripts/shortcuts_issueable.coffee
app/assets/javascripts/shortcuts_issueable.coffee
+3
-0
spec/javascripts/shortcuts_issueable_spec.js.coffee
spec/javascripts/shortcuts_issueable_spec.js.coffee
+83
-0
vendor/assets/javascripts/jasmine-fixture.js
vendor/assets/javascripts/jasmine-fixture.js
+433
-0
No files found.
app/assets/javascripts/shortcuts_issueable.coffee
View file @
8e6fa255
#= require jquery
#= require mousetrap
#= require shortcuts_navigation
class
@
ShortcutsIssueable
extends
ShortcutsNavigation
...
...
spec/javascripts/shortcuts_issueable_spec.js.coffee
0 → 100644
View file @
8e6fa255
#= require jquery
#= require jasmine-fixture
#= require shortcuts_issueable
describe
'ShortcutsIssueable'
,
->
beforeEach
->
@
shortcut
=
new
ShortcutsIssueable
()
describe
'#replyWithSelectedText'
,
->
# Stub window.getSelection to return the provided String.
stubSelection
=
(
text
)
->
window
.
getSelection
=
->
text
beforeEach
->
@
selector
=
'form.js-main-target-form textarea#note_note'
affix
(
@
selector
)
describe
'with empty selection'
,
->
it
'does nothing'
,
->
stubSelection
(
''
)
@
shortcut
.
replyWithSelectedText
()
expect
(
$
(
@
selector
).
val
()).
toBe
(
''
)
describe
'with any selection'
,
->
beforeEach
->
stubSelection
(
'Selected text.'
)
it
'leaves existing input intact'
,
->
$
(
@
selector
).
val
(
'This text was already here.'
)
expect
(
$
(
@
selector
).
val
()).
toBe
(
'This text was already here.'
)
@
shortcut
.
replyWithSelectedText
()
expect
(
$
(
@
selector
).
val
()).
toBe
(
"This text was already here.
\n
> Selected text.
\n\n
"
)
it
'triggers `input`'
,
->
triggered
=
false
$
(
@
selector
).
on
'input'
,
->
triggered
=
true
@
shortcut
.
replyWithSelectedText
()
expect
(
triggered
).
toBe
(
true
)
it
'triggers `focus`'
,
->
focused
=
false
$
(
@
selector
).
on
'focus'
,
->
focused
=
true
@
shortcut
.
replyWithSelectedText
()
expect
(
focused
).
toBe
(
true
)
describe
'with a one-line selection'
,
->
it
'quotes the selection'
,
->
stubSelection
(
'This text has been selected.'
)
@
shortcut
.
replyWithSelectedText
()
expect
(
$
(
@
selector
).
val
()).
toBe
(
"> This text has been selected.
\n\n
"
)
describe
'with a multi-line selection'
,
->
it
'quotes the selected lines as a group'
,
->
stubSelection
(
"""
Selected line one.
Selected line two.
Selected line three.
"""
)
@
shortcut
.
replyWithSelectedText
()
expect
(
$
(
@
selector
).
val
()).
toBe
(
"""
> Selected line one.
> Selected line two.
> Selected line three.
"""
)
vendor/assets/javascripts/jasmine-fixture.js
0 → 100644
View file @
8e6fa255
This diff is collapsed.
Click to expand it.
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