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
4296c365
Commit
4296c365
authored
Feb 12, 2021
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for issuable item href
parent
e8781c00
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
13 deletions
+33
-13
spec/frontend/issuable_list/components/issuable_item_spec.js
spec/frontend/issuable_list/components/issuable_item_spec.js
+33
-13
No files found.
spec/frontend/issuable_list/components/issuable_item_spec.js
View file @
4296c365
...
@@ -18,6 +18,8 @@ const createComponent = ({ issuableSymbol = '#', issuable = mockIssuable, slots
...
@@ -18,6 +18,8 @@ const createComponent = ({ issuableSymbol = '#', issuable = mockIssuable, slots
slots
,
slots
,
});
});
const
MOCK_GITLAB_URL
=
'
http://0.0.0.0:3000
'
;
describe
(
'
IssuableItem
'
,
()
=>
{
describe
(
'
IssuableItem
'
,
()
=>
{
// The mock data is dependent that this is after our default date
// The mock data is dependent that this is after our default date
useFakeDate
(
2020
,
11
,
11
);
useFakeDate
(
2020
,
11
,
11
);
...
@@ -28,7 +30,7 @@ describe('IssuableItem', () => {
...
@@ -28,7 +30,7 @@ describe('IssuableItem', () => {
let
wrapper
;
let
wrapper
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
gon
.
gitlab_url
=
'
http://0.0.0.0:3000
'
;
gon
.
gitlab_url
=
MOCK_GITLAB_URL
;
wrapper
=
createComponent
();
wrapper
=
createComponent
();
});
});
...
@@ -73,11 +75,11 @@ describe('IssuableItem', () => {
...
@@ -73,11 +75,11 @@ describe('IssuableItem', () => {
describe
(
'
isIssuableUrlExternal
'
,
()
=>
{
describe
(
'
isIssuableUrlExternal
'
,
()
=>
{
it
.
each
`
it
.
each
`
issuableWebUrl
| urlType | returnValue
issuableWebUrl | urlType | returnValue
${
'
/gitlab-org/gitlab-test/-/issues/2
'
}
|
${
'
relative
'
}
|
${
false
}
${
'
/gitlab-org/gitlab-test/-/issues/2
'
}
|
${
'
relative
'
}
|
${
false
}
${
'
http://0.0.0.0:3000/gitlab-org/gitlab-test/-/issues/1
'
}
|
${
'
absolute and internal
'
}
|
${
false
}
${
`
${
MOCK_GITLAB_URL
}
/gitlab-org/gitlab-test/-/issues/1`
}
|
${
'
absolute and internal
'
}
|
${
false
}
${
'
http://jira.atlassian.net/browse/IG-1
'
}
|
${
'
external
'
}
|
${
true
}
${
'
http://jira.atlassian.net/browse/IG-1
'
}
|
${
'
external
'
}
|
${
true
}
${
'
https://github.com/gitlabhq/gitlabhq/issues/1
'
}
|
${
'
external
'
}
|
${
true
}
${
'
https://github.com/gitlabhq/gitlabhq/issues/1
'
}
|
${
'
external
'
}
|
${
true
}
`
(
`
(
'
returns $returnValue when `issuable.webUrl` is $urlType
'
,
'
returns $returnValue when `issuable.webUrl` is $urlType
'
,
async
({
issuableWebUrl
,
returnValue
})
=>
{
async
({
issuableWebUrl
,
returnValue
})
=>
{
...
@@ -217,14 +219,32 @@ describe('IssuableItem', () => {
...
@@ -217,14 +219,32 @@ describe('IssuableItem', () => {
});
});
describe
(
'
template
'
,
()
=>
{
describe
(
'
template
'
,
()
=>
{
it
(
'
renders issuable title
'
,
()
=>
{
it
.
each
`
const
titleEl
=
wrapper
.
find
(
'
[data-testid="issuable-title"]
'
);
gitlabWebUrl | webUrl | expectedHref | expectedTarget
${
undefined
}
|
${
`
${
MOCK_GITLAB_URL
}
/issue`
}
|
${
`
${
MOCK_GITLAB_URL
}
/issue`
}
|
${
undefined
}
${
undefined
}
|
${
'
https://jira.com/issue
'
}
|
${
'
https://jira.com/issue
'
}
|
${
'
_blank
'
}
${
'
/gitlab-org/issue
'
}
|
${
'
https://jira.com/issue
'
}
|
${
'
/gitlab-org/issue
'
}
|
${
undefined
}
`
(
'
renders issuable title correctly when `gitlabWebUrl` is `$gitlabWebUrl` and webUrl is `$webUrl`
'
,
async
({
webUrl
,
gitlabWebUrl
,
expectedHref
,
expectedTarget
})
=>
{
wrapper
.
setProps
({
issuable
:
{
...
mockIssuable
,
webUrl
,
gitlabWebUrl
,
},
});
expect
(
titleEl
.
exists
()).
toBe
(
true
);
await
wrapper
.
vm
.
$nextTick
();
expect
(
titleEl
.
find
(
GlLink
).
attributes
(
'
href
'
)).
toBe
(
mockIssuable
.
webUrl
);
expect
(
titleEl
.
find
(
GlLink
).
attributes
(
'
target
'
)).
not
.
toBeDefined
();
const
titleEl
=
wrapper
.
find
(
'
[data-testid="issuable-title"]
'
);
expect
(
titleEl
.
find
(
GlLink
).
text
()).
toBe
(
mockIssuable
.
title
);
});
expect
(
titleEl
.
exists
()).
toBe
(
true
);
expect
(
titleEl
.
find
(
GlLink
).
attributes
(
'
href
'
)).
toBe
(
expectedHref
);
expect
(
titleEl
.
find
(
GlLink
).
attributes
(
'
target
'
)).
toBe
(
expectedTarget
);
expect
(
titleEl
.
find
(
GlLink
).
text
()).
toBe
(
mockIssuable
.
title
);
},
);
it
(
'
renders checkbox when `showCheckbox` prop is true
'
,
async
()
=>
{
it
(
'
renders checkbox when `showCheckbox` prop is true
'
,
async
()
=>
{
wrapper
.
setProps
({
wrapper
.
setProps
({
...
...
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