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
afd941e8
Commit
afd941e8
authored
Feb 04, 2021
by
Jose Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor ci_icon_spec to use vue-test-utils
parent
bd16c6f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
111 deletions
+39
-111
spec/frontend/vue_shared/components/ci_icon_spec.js
spec/frontend/vue_shared/components/ci_icon_spec.js
+39
-111
No files found.
spec/frontend/vue_shared/components/ci_icon_spec.js
View file @
afd941e8
import
Vue
from
'
vue
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
ciIcon
from
'
~/vue_shared/components/ci_icon.vue
'
;
describe
(
'
CI Icon component
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
ciIcon
);
let
vm
;
let
wrapper
;
afterEach
(()
=>
{
vm
.
$destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
it
(
'
should render a span element with an svg
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
{
icon
:
'
status_success
'
,
},
});
expect
(
vm
.
$el
.
tagName
).
toEqual
(
'
SPAN
'
);
expect
(
vm
.
$el
.
querySelector
(
'
span > svg
'
)).
toBeDefined
();
});
it
(
'
should render a success status
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
{
icon
:
'
status_success
'
,
group
:
'
success
'
,
},
});
expect
(
vm
.
$el
.
classList
.
contains
(
'
ci-status-icon-success
'
)).
toEqual
(
true
);
});
it
(
'
should render a failed status
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
{
icon
:
'
status_failed
'
,
group
:
'
failed
'
,
},
});
expect
(
vm
.
$el
.
classList
.
contains
(
'
ci-status-icon-failed
'
)).
toEqual
(
true
);
});
it
(
'
should render success with warnings status
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
{
icon
:
'
status_warning
'
,
group
:
'
warning
'
,
},
});
expect
(
vm
.
$el
.
classList
.
contains
(
'
ci-status-icon-warning
'
)).
toEqual
(
true
);
});
it
(
'
should render pending status
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
{
icon
:
'
status_pending
'
,
group
:
'
pending
'
,
},
wrapper
=
mount
(
ciIcon
,
{
propsData
:
{
status
:
{
icon
:
'
status_success
'
,
},
},
});
expect
(
wrapper
.
find
(
'
span
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
span > svg
'
).
exists
()).
toBe
(
true
);
});
describe
(
'
rendering a status
'
,
()
=>
{
it
.
each
`
icon | group | cssClass
${
'
status_success
'
}
|
${
'
success
'
}
|
${
'
ci-status-icon-success
'
}
${
'
status_failed
'
}
|
${
'
failed
'
}
|
${
'
ci-status-icon-failed
'
}
${
'
status_warning
'
}
|
${
'
warning
'
}
|
${
'
ci-status-icon-warning
'
}
${
'
status_pending
'
}
|
${
'
pending
'
}
|
${
'
ci-status-icon-pending
'
}
${
'
status_running
'
}
|
${
'
running
'
}
|
${
'
ci-status-icon-running
'
}
${
'
status_created
'
}
|
${
'
created
'
}
|
${
'
ci-status-icon-created
'
}
${
'
status_skipped
'
}
|
${
'
skipped
'
}
|
${
'
ci-status-icon-skipped
'
}
${
'
status_canceled
'
}
|
${
'
canceled
'
}
|
${
'
ci-status-icon-canceled
'
}
${
'
status_manual
'
}
|
${
'
manual
'
}
|
${
'
ci-status-icon-manual
'
}
`
(
'
should render a $group status
'
,
({
icon
,
group
,
cssClass
})
=>
{
wrapper
=
mount
(
ciIcon
,
{
propsData
:
{
status
:
{
icon
,
group
,
},
},
});
expect
(
wrapper
.
classes
()).
toContain
(
cssClass
);
});
expect
(
vm
.
$el
.
classList
.
contains
(
'
ci-status-icon-pending
'
)).
toEqual
(
true
);
});
it
(
'
should render running status
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
{
icon
:
'
status_running
'
,
group
:
'
running
'
,
},
});
expect
(
vm
.
$el
.
classList
.
contains
(
'
ci-status-icon-running
'
)).
toEqual
(
true
);
});
it
(
'
should render created status
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
{
icon
:
'
status_created
'
,
group
:
'
created
'
,
},
});
expect
(
vm
.
$el
.
classList
.
contains
(
'
ci-status-icon-created
'
)).
toEqual
(
true
);
});
it
(
'
should render skipped status
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
{
icon
:
'
status_skipped
'
,
group
:
'
skipped
'
,
},
});
expect
(
vm
.
$el
.
classList
.
contains
(
'
ci-status-icon-skipped
'
)).
toEqual
(
true
);
});
it
(
'
should render canceled status
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
{
icon
:
'
status_canceled
'
,
group
:
'
canceled
'
,
},
});
expect
(
vm
.
$el
.
classList
.
contains
(
'
ci-status-icon-canceled
'
)).
toEqual
(
true
);
});
it
(
'
should render status for manual action
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
status
:
{
icon
:
'
status_manual
'
,
group
:
'
manual
'
,
},
});
expect
(
vm
.
$el
.
classList
.
contains
(
'
ci-status-icon-manual
'
)).
toEqual
(
true
);
});
});
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