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
396122a5
Commit
396122a5
authored
Feb 10, 2021
by
Payton Burdette
Committed by
Natalia Tepluhina
Feb 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port spec to vue test utils
Move ci badge link spec over to utilize vue test utils.
parent
8a65ba1f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
20 deletions
+20
-20
spec/frontend/vue_shared/components/ci_badge_link_spec.js
spec/frontend/vue_shared/components/ci_badge_link_spec.js
+20
-20
No files found.
spec/frontend/vue_shared/components/ci_badge_link_spec.js
View file @
396122a5
import
Vue
from
'
vue
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
CiBadge
from
'
~/vue_shared/components/ci_badge_link.vue
'
;
import
ciBadge
from
'
~/vue_shared/components/ci_badge_link
.vue
'
;
import
CiIcon
from
'
~/vue_shared/components/ci_icon
.vue
'
;
describe
(
'
CI Badge Link Component
'
,
()
=>
{
describe
(
'
CI Badge Link Component
'
,
()
=>
{
let
CIBadge
;
let
wrapper
;
let
vm
;
const
statuses
=
{
const
statuses
=
{
canceled
:
{
canceled
:
{
...
@@ -72,29 +71,30 @@ describe('CI Badge Link Component', () => {
...
@@ -72,29 +71,30 @@ describe('CI Badge Link Component', () => {
},
},
};
};
beforeEach
(()
=>
{
const
findIcon
=
()
=>
wrapper
.
findComponent
(
CiIcon
);
CIBadge
=
Vue
.
extend
(
ciBadge
);
});
const
createComponent
=
(
propsData
)
=>
{
wrapper
=
shallowMount
(
CiBadge
,
{
propsData
});
};
afterEach
(()
=>
{
afterEach
(()
=>
{
vm
.
$destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
it
(
'
should render each status badge
'
,
()
=>
{
it
.
each
(
Object
.
keys
(
statuses
))(
'
should render badge for status: %s
'
,
(
status
)
=>
{
Object
.
keys
(
statuses
).
map
((
status
)
=>
{
createComponent
({
status
:
statuses
[
status
]
});
vm
=
mountComponent
(
CIBadge
,
{
status
:
statuses
[
status
]
});
expect
(
vm
.
$el
.
getAttribute
(
'
href
'
)).
toEqual
(
statuses
[
status
].
details_path
);
expect
(
wrapper
.
attributes
(
'
href
'
)).
toBe
(
statuses
[
status
].
details_path
);
expect
(
vm
.
$el
.
textContent
.
trim
()).
toEqual
(
statuses
[
status
].
text
);
expect
(
wrapper
.
text
()).
toBe
(
statuses
[
status
].
text
);
expect
(
vm
.
$el
.
getAttribute
(
'
class
'
)).
toContain
(
`ci-status ci-
${
statuses
[
status
].
group
}
`
);
expect
(
wrapper
.
classes
()).
toContain
(
'
ci-status
'
);
expect
(
vm
.
$el
.
querySelector
(
'
svg
'
)).
toBeDefined
();
expect
(
wrapper
.
classes
()).
toContain
(
`ci-
${
statuses
[
status
].
group
}
`
);
return
vm
;
expect
(
findIcon
().
exists
()).
toBe
(
true
);
});
});
});
it
(
'
should not render label
'
,
()
=>
{
it
(
'
should not render label
'
,
()
=>
{
vm
=
mountComponent
(
CIBadge
,
{
status
:
statuses
.
canceled
,
showText
:
false
});
createComponent
(
{
status
:
statuses
.
canceled
,
showText
:
false
});
expect
(
vm
.
$el
.
textContent
.
trim
()).
toEqual
(
''
);
expect
(
wrapper
.
text
()).
toBe
(
''
);
});
});
});
});
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