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
be352be2
Commit
be352be2
authored
Oct 27, 2020
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use param spec in pipeline_status_badge_spec
This way we're not creating the subject twice
parent
8ded239f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
19 deletions
+13
-19
ee/spec/frontend/security_dashboard/components/pipeline_status_badge_spec.js
...curity_dashboard/components/pipeline_status_badge_spec.js
+13
-19
No files found.
ee/spec/frontend/security_dashboard/components/pipeline_status_badge_spec.js
View file @
be352be2
import
{
merge
}
from
'
lodash
'
;
import
{
GlBadge
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
PipelineStatusBadge
from
'
ee/security_dashboard/components/pipeline_status_badge.vue
'
;
...
...
@@ -6,21 +7,15 @@ describe('Pipeline status badge', () => {
let
wrapper
;
const
securityBuildsFailedPath
=
'
/some/path/to/failed/jobs
'
;
const
DEFAULT_PROPS
=
{
pipeline
:
{
securityBuildsFailedCount
:
5
,
securityBuildsFailedPath
,
},
};
const
findGlBadge
=
()
=>
wrapper
.
find
(
GlBadge
);
const
findGlIcon
=
()
=>
wrapper
.
find
(
GlIcon
);
const
createProps
=
securityBuildsFailedCount
=>
({
pipeline
:
{
securityBuildsFailedCount
}
});
const
createWrapper
=
(
{
props
=
{}
}
=
{})
=>
{
const
createWrapper
=
(
props
=
{})
=>
{
wrapper
=
shallowMount
(
PipelineStatusBadge
,
{
propsData
:
{
...
DEFAULT_PROPS
,
...
props
}
,
propsData
:
merge
({
pipeline
:
{
securityBuildsFailedPath
}
},
props
)
,
});
};
...
...
@@ -29,34 +24,33 @@ describe('Pipeline status badge', () => {
wrapper
=
null
;
});
describe
(
'
when there are more than 0 failed jobs
'
,
()
=>
{
describe
.
each
`
failedCount | expectedMessage
${
7
}
|
${
'
7 failed security jobs
'
}
${
1
}
|
${
'
1 failed security job
'
}
`
(
'
when there are failed jobs ($failedCount)
'
,
({
failedCount
,
expectedMessage
})
=>
{
beforeEach
(()
=>
{
createWrapper
();
createWrapper
(
createProps
(
failedCount
)
);
});
it
(
'
displays correct message
for 5 failed jobs
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toBe
(
'
5 failed security jobs
'
);
it
(
'
displays correct message
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toBe
(
expectedMessage
);
});
it
(
'
links to the correct path
'
,
()
=>
{
expect
(
findGlBadge
().
attributes
(
'
href
'
)).
toBe
(
securityBuildsFailedPath
);
});
it
(
'
displays correct message for 1 failed job
'
,
()
=>
{
createWrapper
({
props
:
createProps
(
1
)
});
expect
(
wrapper
.
text
()).
toBe
(
'
1 failed security job
'
);
});
});
describe
(
'
when there are not more than 0 failed jobs
'
,
()
=>
{
it
(
'
does not display when there are 0 failed jobs
'
,
()
=>
{
createWrapper
(
{
props
:
createProps
(
0
)
}
);
createWrapper
(
createProps
(
0
)
);
expect
(
findGlBadge
().
exists
()).
toBe
(
false
);
expect
(
findGlIcon
().
exists
()).
toBe
(
false
);
});
it
(
'
does not display when there is no failed jobs count
'
,
()
=>
{
createWrapper
(
{
props
:
createProps
(
undefined
)
}
);
createWrapper
();
expect
(
findGlBadge
().
exists
()).
toBe
(
false
);
expect
(
findGlIcon
().
exists
()).
toBe
(
false
);
});
...
...
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