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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
3bcc26ef
Commit
3bcc26ef
authored
Nov 21, 2019
by
Utkarsh Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove var from line_highlighter_spec.js
parent
1f8c149a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
27 deletions
+14
-27
spec/javascripts/line_highlighter_spec.js
spec/javascripts/line_highlighter_spec.js
+14
-27
No files found.
spec/javascripts/line_highlighter_spec.js
View file @
3bcc26ef
/* eslint-disable no-
var, no-
else-return, dot-notation, no-return-assign, no-new, no-underscore-dangle */
/* eslint-disable no-else-return, dot-notation, no-return-assign, no-new, no-underscore-dangle */
import
$
from
'
jquery
'
;
import
LineHighlighter
from
'
~/line_highlighter
'
;
describe
(
'
LineHighlighter
'
,
function
()
{
var
clickLine
;
preloadFixtures
(
'
static/line_highlighter.html
'
);
clickLine
=
function
(
number
,
eventData
=
{})
{
c
onst
c
lickLine
=
function
(
number
,
eventData
=
{})
{
if
(
$
.
isEmptyObject
(
eventData
))
{
return
$
(
`#L
${
number
}
`
).
click
();
}
else
{
...
...
@@ -39,34 +38,30 @@ describe('LineHighlighter', function() {
});
it
(
'
highlights a range of lines given in the URL hash
'
,
function
()
{
var
line
;
new
LineHighlighter
({
hash
:
'
#L5-25
'
});
expect
(
$
(
`.
${
this
.
css
}
`
).
length
).
toBe
(
21
);
for
(
line
=
5
;
line
<=
25
;
line
+=
1
)
{
for
(
l
et
l
ine
=
5
;
line
<=
25
;
line
+=
1
)
{
expect
(
$
(
`#LC
${
line
}
`
)).
toHaveClass
(
this
.
css
);
}
});
it
(
'
scrolls to the first highlighted line on initial load
'
,
function
()
{
var
spy
;
spy
=
spyOn
(
$
,
'
scrollTo
'
);
const
spy
=
spyOn
(
$
,
'
scrollTo
'
);
new
LineHighlighter
({
hash
:
'
#L5-25
'
});
expect
(
spy
).
toHaveBeenCalledWith
(
'
#L5
'
,
jasmine
.
anything
());
});
it
(
'
discards click events
'
,
function
()
{
var
spy
;
spy
=
spyOnEvent
(
'
a[data-line-number]
'
,
'
click
'
);
const
spy
=
spyOnEvent
(
'
a[data-line-number]
'
,
'
click
'
);
clickLine
(
13
);
expect
(
spy
).
toHaveBeenPrevented
();
});
it
(
'
handles garbage input from the hash
'
,
function
()
{
var
func
;
func
=
function
()
{
const
func
=
function
()
{
return
new
LineHighlighter
({
fileHolderSelector
:
'
#blob-content-holder
'
});
};
...
...
@@ -76,8 +71,7 @@ describe('LineHighlighter', function() {
describe
(
'
clickHandler
'
,
function
()
{
it
(
'
handles clicking on a child icon element
'
,
function
()
{
var
spy
;
spy
=
spyOn
(
this
[
'
class
'
],
'
setHash
'
).
and
.
callThrough
();
const
spy
=
spyOn
(
this
[
'
class
'
],
'
setHash
'
).
and
.
callThrough
();
$
(
'
#L13 i
'
)
.
mousedown
()
.
click
();
...
...
@@ -102,8 +96,7 @@ describe('LineHighlighter', function() {
});
it
(
'
sets the hash
'
,
function
()
{
var
spy
;
spy
=
spyOn
(
this
[
'
class
'
],
'
setHash
'
).
and
.
callThrough
();
const
spy
=
spyOn
(
this
[
'
class
'
],
'
setHash
'
).
and
.
callThrough
();
clickLine
(
13
);
expect
(
spy
).
toHaveBeenCalledWith
(
13
);
...
...
@@ -112,8 +105,7 @@ describe('LineHighlighter', function() {
describe
(
'
with shiftKey
'
,
function
()
{
it
(
'
sets the hash
'
,
function
()
{
var
spy
;
spy
=
spyOn
(
this
[
'
class
'
],
'
setHash
'
).
and
.
callThrough
();
const
spy
=
spyOn
(
this
[
'
class
'
],
'
setHash
'
).
and
.
callThrough
();
clickLine
(
13
);
clickLine
(
20
,
{
shiftKey
:
true
,
...
...
@@ -134,8 +126,7 @@ describe('LineHighlighter', function() {
});
it
(
'
sets the hash
'
,
function
()
{
var
spy
;
spy
=
spyOn
(
this
[
'
class
'
],
'
setHash
'
);
const
spy
=
spyOn
(
this
[
'
class
'
],
'
setHash
'
);
clickLine
(
13
,
{
shiftKey
:
true
,
});
...
...
@@ -146,27 +137,25 @@ describe('LineHighlighter', function() {
describe
(
'
with existing single-line highlight
'
,
function
()
{
it
(
'
uses existing line as last line when target is lesser
'
,
function
()
{
var
line
;
clickLine
(
20
);
clickLine
(
15
,
{
shiftKey
:
true
,
});
expect
(
$
(
`.
${
this
.
css
}
`
).
length
).
toBe
(
6
);
for
(
line
=
15
;
line
<=
20
;
line
+=
1
)
{
for
(
l
et
l
ine
=
15
;
line
<=
20
;
line
+=
1
)
{
expect
(
$
(
`#LC
${
line
}
`
)).
toHaveClass
(
this
.
css
);
}
});
it
(
'
uses existing line as first line when target is greater
'
,
function
()
{
var
line
;
clickLine
(
5
);
clickLine
(
10
,
{
shiftKey
:
true
,
});
expect
(
$
(
`.
${
this
.
css
}
`
).
length
).
toBe
(
6
);
for
(
line
=
5
;
line
<=
10
;
line
+=
1
)
{
for
(
l
et
l
ine
=
5
;
line
<=
10
;
line
+=
1
)
{
expect
(
$
(
`#LC
${
line
}
`
)).
toHaveClass
(
this
.
css
);
}
});
...
...
@@ -183,25 +172,23 @@ describe('LineHighlighter', function() {
});
it
(
'
uses target as first line when it is less than existing first line
'
,
function
()
{
var
line
;
clickLine
(
5
,
{
shiftKey
:
true
,
});
expect
(
$
(
`.
${
this
.
css
}
`
).
length
).
toBe
(
6
);
for
(
line
=
5
;
line
<=
10
;
line
+=
1
)
{
for
(
l
et
l
ine
=
5
;
line
<=
10
;
line
+=
1
)
{
expect
(
$
(
`#LC
${
line
}
`
)).
toHaveClass
(
this
.
css
);
}
});
it
(
'
uses target as last line when it is greater than existing first line
'
,
function
()
{
var
line
;
clickLine
(
15
,
{
shiftKey
:
true
,
});
expect
(
$
(
`.
${
this
.
css
}
`
).
length
).
toBe
(
6
);
for
(
line
=
10
;
line
<=
15
;
line
+=
1
)
{
for
(
l
et
l
ine
=
10
;
line
<=
15
;
line
+=
1
)
{
expect
(
$
(
`#LC
${
line
}
`
)).
toHaveClass
(
this
.
css
);
}
});
...
...
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