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
Boxiang Sun
gitlab-ce
Commits
855c258f
Commit
855c258f
authored
Sep 12, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed todos spec
parent
08362d80
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
28 deletions
+15
-28
app/assets/javascripts/todos.js
app/assets/javascripts/todos.js
+6
-11
spec/javascripts/todos_spec.js
spec/javascripts/todos_spec.js
+9
-17
No files found.
app/assets/javascripts/todos.js
View file @
855c258f
...
@@ -138,22 +138,17 @@ export default class Todos {
...
@@ -138,22 +138,17 @@ export default class Todos {
goToTodoUrl
(
e
)
{
goToTodoUrl
(
e
)
{
const
todoLink
=
this
.
dataset
.
url
;
const
todoLink
=
this
.
dataset
.
url
;
if
(
!
todoLink
)
{
if
(
!
todoLink
||
e
.
target
.
tagName
===
'
A
'
||
e
.
target
.
tagName
===
'
IMG
'
)
{
return
;
return
;
}
}
if
(
isMetaClick
(
e
))
{
const
windowTarget
=
'
_blank
'
;
const
selected
=
e
.
target
;
e
.
stopPropagation
();
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
preventDefault
();
if
(
selected
.
tagName
===
'
IMG
'
)
{
if
(
isMetaClick
(
e
))
{
const
avatarUrl
=
selected
.
parentElement
.
getAttribute
(
'
href
'
);
const
windowTarget
=
'
_blank
'
;
window
.
open
(
avatarUrl
,
windowTarget
);
}
else
{
window
.
open
(
todoLink
,
windowTarget
);
window
.
open
(
todoLink
,
windowTarget
);
}
}
else
{
}
else
{
gl
.
utils
.
visitUrl
(
todoLink
);
gl
.
utils
.
visitUrl
(
todoLink
);
}
}
...
...
spec/javascripts/todos_spec.js
View file @
855c258f
...
@@ -26,38 +26,30 @@ describe('Todos', () => {
...
@@ -26,38 +26,30 @@ describe('Todos', () => {
describe
(
'
meta click
'
,
()
=>
{
describe
(
'
meta click
'
,
()
=>
{
let
visitUrlSpy
;
let
visitUrlSpy
;
let
windowOpenSpy
;
let
metakeyEvent
;
let
metakeyEvent
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
metakeyEvent
=
$
.
Event
(
'
click
'
,
{
keyCode
:
91
,
ctrlKey
:
true
});
metakeyEvent
=
$
.
Event
(
'
click
'
,
{
keyCode
:
91
,
ctrlKey
:
true
});
visitUrlSpy
=
spyOn
(
gl
.
utils
,
'
visitUrl
'
).
and
.
callFake
(()
=>
{});
visitUrlSpy
=
spyOn
(
gl
.
utils
,
'
visitUrl
'
).
and
.
callFake
(()
=>
{});
windowOpenSpy
=
spyOn
(
window
,
'
open
'
).
and
.
callFake
(()
=>
{});
});
});
it
(
'
opens the todo url in another tab
'
,
(
done
)
=>
{
it
(
'
opens the todo url in another tab
'
,
()
=>
{
const
todoLink
=
todoItem
.
dataset
.
url
;
const
todoLink
=
todoItem
.
dataset
.
url
;
spyOn
(
window
,
'
open
'
).
and
.
callFake
((
url
,
target
)
=>
{
expect
(
todoLink
).
toEqual
(
url
);
expect
(
target
).
toEqual
(
'
_blank
'
);
done
();
});
$
(
'
.todos-list .todo
'
).
trigger
(
metakeyEvent
);
$
(
'
.todos-list .todo
'
).
trigger
(
metakeyEvent
);
expect
(
visitUrlSpy
).
not
.
toHaveBeenCalled
();
expect
(
visitUrlSpy
).
not
.
toHaveBeenCalled
();
expect
(
windowOpenSpy
).
toHaveBeenCalledWith
(
todoLink
,
'
_blank
'
);
});
});
it
(
'
opens the avatar
\'
s url in another tab when the avatar is clicked
'
,
(
done
)
=>
{
it
(
'
run native funcionality when avatar is clicked
'
,
()
=>
{
const
avatarImage
=
todoItem
.
querySelector
(
'
img
'
);
$
(
'
.todos-list a
'
).
on
(
'
click
'
,
e
=>
e
.
preventDefault
());
const
avatarUrl
=
avatarImage
.
parentElement
.
getAttribute
(
'
href
'
);
$
(
'
.todos-list img
'
).
trigger
(
metakeyEvent
);
spyOn
(
window
,
'
open
'
).
and
.
callFake
((
url
,
target
)
=>
{
expect
(
avatarUrl
).
toEqual
(
url
);
expect
(
target
).
toEqual
(
'
_blank
'
);
done
();
});
avatarImage
.
click
();
expect
(
visitUrlSpy
).
not
.
toHaveBeenCalled
();
expect
(
visitUrlSpy
).
not
.
toHaveBeenCalled
();
expect
(
windowOpenSpy
).
not
.
toHaveBeenCalled
();
});
});
});
});
});
});
...
...
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