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
c855daec
Commit
c855daec
authored
Aug 21, 2020
by
Scott Hampton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a utils spec
Added a utils spec file to test the formattedTime util function.
parent
dce6ba76
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
app/assets/javascripts/pipelines/stores/test_reports/utils.js
...assets/javascripts/pipelines/stores/test_reports/utils.js
+1
-2
spec/frontend/pipelines/test_reports/stores/utils_spec.js
spec/frontend/pipelines/test_reports/stores/utils_spec.js
+26
-0
No files found.
app/assets/javascripts/pipelines/stores/test_reports/utils.js
View file @
c855daec
import
{
TestStatus
}
from
'
~/pipelines/constants
'
;
import
{
secondsToMilliseconds
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
__
,
sprintf
}
from
'
../../../locale
'
;
export
function
iconForTestStatus
(
status
)
{
...
...
@@ -15,7 +14,7 @@ export function iconForTestStatus(status) {
export
const
formattedTime
=
(
seconds
=
0
)
=>
{
if
(
seconds
<
1
)
{
const
milliseconds
=
seconds
ToMilliseconds
(
seconds
)
;
const
milliseconds
=
seconds
*
1000
;
return
sprintf
(
__
(
'
%{milliseconds}ms
'
),
{
milliseconds
:
milliseconds
.
toFixed
(
2
)
});
}
return
sprintf
(
__
(
'
%{seconds}s
'
),
{
seconds
:
seconds
.
toFixed
(
2
)
});
...
...
spec/frontend/pipelines/test_reports/stores/utils_spec.js
0 → 100644
View file @
c855daec
import
{
formattedTime
}
from
'
~/pipelines/stores/test_reports/utils
'
;
describe
(
'
Test reports utils
'
,
()
=>
{
describe
(
'
formattedTime
'
,
()
=>
{
describe
(
'
when time is smaller than a second
'
,
()
=>
{
it
(
'
should return time in milliseconds fixed to 2 decimals
'
,
()
=>
{
const
result
=
formattedTime
(
0.4815162342
);
expect
(
result
).
toBe
(
'
481.52ms
'
);
});
});
describe
(
'
when time is equal to a second
'
,
()
=>
{
it
(
'
should return time in seconds fixed to 2 decimals
'
,
()
=>
{
const
result
=
formattedTime
(
1
);
expect
(
result
).
toBe
(
'
1.00s
'
);
});
});
describe
(
'
when time is greater than a second
'
,
()
=>
{
it
(
'
should return time in seconds fixed to 2 decimals
'
,
()
=>
{
const
result
=
formattedTime
(
4.815162342
);
expect
(
result
).
toBe
(
'
4.82s
'
);
});
});
});
});
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