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
Léo-Paul Géneau
gitlab-ce
Commits
5f5995dd
Commit
5f5995dd
authored
Apr 16, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added specs to message_field.vue
parent
f4902026
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
183 additions
and
3 deletions
+183
-3
app/assets/javascripts/ide/components/commit_sidebar/message_field.vue
...vascripts/ide/components/commit_sidebar/message_field.vue
+9
-3
spec/javascripts/ide/components/commit_sidebar/message_field_spec.js
...ripts/ide/components/commit_sidebar/message_field_spec.js
+174
-0
No files found.
app/assets/javascripts/ide/components/commit_sidebar/message_field.vue
View file @
5f5995dd
...
@@ -29,7 +29,9 @@ export default {
...
@@ -29,7 +29,9 @@ export default {
methods
:
{
methods
:
{
handleScroll
()
{
handleScroll
()
{
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
if
(
this
.
$refs
.
textarea
)
{
this
.
scrollTop
=
this
.
$refs
.
textarea
.
scrollTop
;
this
.
scrollTop
=
this
.
$refs
.
textarea
.
scrollTop
;
}
});
});
},
},
getLineLength
(
i
)
{
getLineLength
(
i
)
{
...
@@ -38,6 +40,9 @@ export default {
...
@@ -38,6 +40,9 @@ export default {
onInput
(
e
)
{
onInput
(
e
)
{
this
.
$emit
(
'
input
'
,
e
.
target
.
value
);
this
.
$emit
(
'
input
'
,
e
.
target
.
value
);
},
},
updateIsFocused
(
isFocused
)
{
this
.
isFocused
=
isFocused
;
},
},
},
popoverOptions
:
{
popoverOptions
:
{
html
:
true
,
html
:
true
,
...
@@ -103,12 +108,13 @@ export default {
...
@@ -103,12 +108,13 @@ export default {
</div>
</div>
<textarea
<textarea
class=
"note-textarea ide-commit-message-textarea"
class=
"note-textarea ide-commit-message-textarea"
name=
"commit-message"
:placeholder=
"__('Write a commit message...')"
:placeholder=
"__('Write a commit message...')"
:value=
"text"
:value=
"text"
@
scroll=
"handleScroll"
@
scroll=
"handleScroll"
@
input=
"onInput"
@
input=
"onInput"
@
focus=
"
isFocused = true
"
@
focus=
"
updateIsFocused(true)
"
@
blur=
"
isFocused = false
"
@
blur=
"
updateIsFocused(false)
"
ref=
"textarea"
ref=
"textarea"
>
>
</textarea>
</textarea>
...
...
spec/javascripts/ide/components/commit_sidebar/message_field_spec.js
0 → 100644
View file @
5f5995dd
import
Vue
from
'
vue
'
;
import
CommitMessageField
from
'
~/ide/components/commit_sidebar/message_field.vue
'
;
import
createComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
describe
(
'
IDE commit message field
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
CommitMessageField
);
let
vm
;
beforeEach
(()
=>
{
setFixtures
(
'
<div id="app"></div>
'
);
vm
=
createComponent
(
Component
,
{
text
:
''
,
},
'
#app
'
,
);
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
it
(
'
adds is-focused class on focus
'
,
done
=>
{
vm
.
$el
.
querySelector
(
'
textarea
'
).
focus
();
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.is-focused
'
)).
not
.
toBeNull
();
done
();
});
});
it
(
'
removed is-focused class on blur
'
,
done
=>
{
vm
.
$el
.
querySelector
(
'
textarea
'
).
focus
();
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.is-focused
'
)).
not
.
toBeNull
();
vm
.
$el
.
querySelector
(
'
textarea
'
).
blur
();
return
vm
.
$nextTick
();
})
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.is-focused
'
)).
toBeNull
();
done
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
emits input event on input
'
,
()
=>
{
spyOn
(
vm
,
'
$emit
'
);
const
textarea
=
vm
.
$el
.
querySelector
(
'
textarea
'
);
textarea
.
value
=
'
testing
'
;
textarea
.
dispatchEvent
(
new
Event
(
'
input
'
));
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
input
'
,
'
testing
'
);
});
describe
(
'
highlights
'
,
()
=>
{
describe
(
'
subject line
'
,
()
=>
{
it
(
'
does not highlight less than 50 characters
'
,
done
=>
{
vm
.
text
=
'
text less than 50 chars
'
;
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.highlights span
'
).
textContent
).
toContain
(
'
text less than 50 chars
'
,
);
expect
(
vm
.
$el
.
querySelector
(
'
mark
'
)).
toBeNull
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
highlights characters over 50 length
'
,
done
=>
{
vm
.
text
=
'
text less than 50 chars that should not highlighted. text more than 50 should be highlighted
'
;
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.highlights span
'
).
textContent
).
toContain
(
'
text less than 50 chars that should not highlighte
'
,
);
expect
(
vm
.
$el
.
querySelector
(
'
mark
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
mark
'
).
textContent
).
toBe
(
'
d. text more than 50 should be highlighted
'
,
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
describe
(
'
body text
'
,
()
=>
{
it
(
'
does not highlight body text less tan 72 characters
'
,
done
=>
{
vm
.
text
=
'
subject line
\n
body content
'
;
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.highlights span
'
).
length
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelector
(
'
mark
'
)).
toBeNull
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
highlights body text more than 72 characters
'
,
done
=>
{
vm
.
text
=
'
subject line
\n
body content that will be highlighted when it is more than 72 characters in length
'
;
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.highlights span
'
).
length
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelector
(
'
mark
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
mark
'
).
textContent
).
toBe
(
'
in length
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
highlights body text & subject line
'
,
done
=>
{
vm
.
text
=
'
text less than 50 chars that should not highlighted
\n
body content that will be highlighted when it is more than 72 characters in length
'
;
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.highlights span
'
).
length
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
).
length
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
)[
0
].
textContent
).
toContain
(
'
d
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
mark
'
)[
1
].
textContent
).
toBe
(
'
in length
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
describe
(
'
scrolling textarea
'
,
()
=>
{
it
(
'
updates transform of highlights
'
,
done
=>
{
vm
.
text
=
'
subject line
\n\n\n\n\n\n\n\n\n\n\n
body content
'
;
vm
.
$nextTick
()
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
textarea
'
).
scrollTo
(
0
,
50
);
vm
.
handleScroll
();
})
.
then
(
vm
.
$nextTick
)
.
then
(()
=>
{
expect
(
vm
.
scrollTop
).
toBe
(
50
);
expect
(
vm
.
$el
.
querySelector
(
'
.highlights
'
).
style
.
transform
).
toBe
(
'
translate3d(0px, -50px, 0px)
'
,
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
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