Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-05 12:12:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-05 12:12:42 +0300
commit2a134be97dafb4743eee8fc908463136ddf23b1f (patch)
tree43ce3854f0a69a5938db1a56abc20cdce3517a52 /spec/frontend/lib
parent7c0c3a7dc95668d20ec8f4bbc2d505f373b6032a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib')
-rw-r--r--spec/frontend/lib/utils/datetime/date_format_utility_spec.js17
-rw-r--r--spec/frontend/lib/utils/datetime_utility_spec.js40
2 files changed, 28 insertions, 29 deletions
diff --git a/spec/frontend/lib/utils/datetime/date_format_utility_spec.js b/spec/frontend/lib/utils/datetime/date_format_utility_spec.js
index 6b515e9f96a..e7a6367eeac 100644
--- a/spec/frontend/lib/utils/datetime/date_format_utility_spec.js
+++ b/spec/frontend/lib/utils/datetime/date_format_utility_spec.js
@@ -134,23 +134,6 @@ describe('formatTimeAsSummary', () => {
});
});
-describe('durationTimeFormatted', () => {
- it.each`
- duration | expectedOutput
- ${0} | ${'00:00:00'}
- ${12} | ${'00:00:12'}
- ${60} | ${'00:01:00'}
- ${60 + 27} | ${'00:01:27'}
- ${120 + 21} | ${'00:02:21'}
- ${4 * 60 * 60 + 25 * 60 + 37} | ${'04:25:37'}
- ${35 * 60 * 60 + 3 * 60 + 7} | ${'35:03:07'}
- ${-60} | ${'-00:01:00'}
- ${-(35 * 60 * 60 + 3 * 60 + 7)} | ${'-35:03:07'}
- `('returns $expectedOutput when provided $duration', ({ duration, expectedOutput }) => {
- expect(utils.durationTimeFormatted(duration)).toBe(expectedOutput);
- });
-});
-
describe('formatUtcOffset', () => {
it.each`
offset | expected
diff --git a/spec/frontend/lib/utils/datetime_utility_spec.js b/spec/frontend/lib/utils/datetime_utility_spec.js
index 8d989350173..330bfca7029 100644
--- a/spec/frontend/lib/utils/datetime_utility_spec.js
+++ b/spec/frontend/lib/utils/datetime_utility_spec.js
@@ -276,19 +276,35 @@ describe('getTimeframeWindowFrom', () => {
});
describe('formatTime', () => {
- const expectedTimestamps = [
- [0, '00:00:00'],
- [1000, '00:00:01'],
- [42000, '00:00:42'],
- [121000, '00:02:01'],
- [10921000, '03:02:01'],
- [108000000, '30:00:00'],
- ];
+ it.each`
+ milliseconds | expected
+ ${0} | ${'00:00:00'}
+ ${1} | ${'00:00:00'}
+ ${499} | ${'00:00:00'}
+ ${500} | ${'00:00:01'}
+ ${1000} | ${'00:00:01'}
+ ${42 * 1000} | ${'00:00:42'}
+ ${60 * 1000} | ${'00:01:00'}
+ ${(60 + 1) * 1000} | ${'00:01:01'}
+ ${(3 * 60 * 60 + 2 * 60 + 1) * 1000} | ${'03:02:01'}
+ ${(11 * 60 * 60 + 59 * 60 + 59) * 1000} | ${'11:59:59'}
+ ${30 * 60 * 60 * 1000} | ${'30:00:00'}
+ ${(35 * 60 * 60 + 3 * 60 + 7) * 1000} | ${'35:03:07'}
+ ${240 * 60 * 60 * 1000} | ${'240:00:00'}
+ ${1000 * 60 * 60 * 1000} | ${'1000:00:00'}
+ `(`formats $milliseconds ms as $expected`, ({ milliseconds, expected }) => {
+ expect(datetimeUtility.formatTime(milliseconds)).toBe(expected);
+ });
- expectedTimestamps.forEach(([milliseconds, expectedTimestamp]) => {
- it(`formats ${milliseconds}ms as ${expectedTimestamp}`, () => {
- expect(datetimeUtility.formatTime(milliseconds)).toBe(expectedTimestamp);
- });
+ it.each`
+ milliseconds | expected
+ ${-1} | ${'00:00:00'}
+ ${-499} | ${'00:00:00'}
+ ${-1000} | ${'-00:00:01'}
+ ${-60 * 1000} | ${'-00:01:00'}
+ ${-(35 * 60 * 60 + 3 * 60 + 7) * 1000} | ${'-35:03:07'}
+ `(`when negative, formats $milliseconds ms as $expected`, ({ milliseconds, expected }) => {
+ expect(datetimeUtility.formatTime(milliseconds)).toBe(expected);
});
});