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:
Diffstat (limited to 'spec/frontend/lib')
-rw-r--r--spec/frontend/lib/utils/datetime/date_calculation_utility_spec.js18
-rw-r--r--spec/frontend/lib/utils/datetime/date_format_utility_spec.js22
-rw-r--r--spec/frontend/lib/utils/poll_until_complete_spec.js14
3 files changed, 38 insertions, 16 deletions
diff --git a/spec/frontend/lib/utils/datetime/date_calculation_utility_spec.js b/spec/frontend/lib/utils/datetime/date_calculation_utility_spec.js
index 055d57d6ada..8d6ace165ab 100644
--- a/spec/frontend/lib/utils/datetime/date_calculation_utility_spec.js
+++ b/spec/frontend/lib/utils/datetime/date_calculation_utility_spec.js
@@ -3,7 +3,9 @@ import {
newDateAsLocaleTime,
nSecondsAfter,
nSecondsBefore,
+ isToday,
} from '~/lib/utils/datetime/date_calculation_utility';
+import { useFakeDate } from 'helpers/fake_date';
describe('newDateAsLocaleTime', () => {
it.each`
@@ -66,3 +68,19 @@ describe('nSecondsBefore', () => {
expect(nSecondsBefore(date, seconds)).toEqual(expected);
});
});
+
+describe('isToday', () => {
+ useFakeDate(2022, 11, 5);
+
+ describe('when date is today', () => {
+ it('returns `true`', () => {
+ expect(isToday(new Date(2022, 11, 5))).toBe(true);
+ });
+ });
+
+ describe('when date is not today', () => {
+ it('returns `false`', () => {
+ expect(isToday(new Date(2022, 11, 6))).toBe(false);
+ });
+ });
+});
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 2e0bb6a8dcd..a83b0ed9fbe 100644
--- a/spec/frontend/lib/utils/datetime/date_format_utility_spec.js
+++ b/spec/frontend/lib/utils/datetime/date_format_utility_spec.js
@@ -149,17 +149,17 @@ describe('durationTimeFormatted', () => {
describe('formatUtcOffset', () => {
it.each`
offset | expected
- ${-32400} | ${'- 9'}
- ${'-12600'} | ${'- 3.5'}
- ${0} | ${'0'}
- ${'10800'} | ${'+ 3'}
- ${19800} | ${'+ 5.5'}
- ${0} | ${'0'}
- ${[]} | ${'0'}
- ${{}} | ${'0'}
- ${true} | ${'0'}
- ${null} | ${'0'}
- ${undefined} | ${'0'}
+ ${-32400} | ${'-9'}
+ ${'-12600'} | ${'-3.5'}
+ ${0} | ${' 0'}
+ ${'10800'} | ${'+3'}
+ ${19800} | ${'+5.5'}
+ ${0} | ${' 0'}
+ ${[]} | ${' 0'}
+ ${{}} | ${' 0'}
+ ${true} | ${' 0'}
+ ${null} | ${' 0'}
+ ${undefined} | ${' 0'}
`('returns $expected given $offset', ({ offset, expected }) => {
expect(utils.formatUtcOffset(offset)).toEqual(expected);
});
diff --git a/spec/frontend/lib/utils/poll_until_complete_spec.js b/spec/frontend/lib/utils/poll_until_complete_spec.js
index 3ce17ecfc8c..309e0cc540b 100644
--- a/spec/frontend/lib/utils/poll_until_complete_spec.js
+++ b/spec/frontend/lib/utils/poll_until_complete_spec.js
@@ -1,7 +1,11 @@
import AxiosMockAdapter from 'axios-mock-adapter';
import { TEST_HOST } from 'helpers/test_constants';
import axios from '~/lib/utils/axios_utils';
-import httpStatusCodes, { HTTP_STATUS_NO_CONTENT } from '~/lib/utils/http_status';
+import {
+ HTTP_STATUS_NO_CONTENT,
+ HTTP_STATUS_NOT_FOUND,
+ HTTP_STATUS_OK,
+} from '~/lib/utils/http_status';
import pollUntilComplete from '~/lib/utils/poll_until_complete';
const endpoint = `${TEST_HOST}/foo`;
@@ -24,7 +28,7 @@ describe('pollUntilComplete', () => {
describe('given an immediate success response', () => {
beforeEach(() => {
- mock.onGet(endpoint).replyOnce(httpStatusCodes.OK, mockData);
+ mock.onGet(endpoint).replyOnce(HTTP_STATUS_OK, mockData);
});
it('resolves with the response', () =>
@@ -39,7 +43,7 @@ describe('pollUntilComplete', () => {
.onGet(endpoint)
.replyOnce(HTTP_STATUS_NO_CONTENT, undefined, pollIntervalHeader)
.onGet(endpoint)
- .replyOnce(httpStatusCodes.OK, mockData);
+ .replyOnce(HTTP_STATUS_OK, mockData);
});
it('calls the endpoint until it succeeds, and resolves with the response', () =>
@@ -66,7 +70,7 @@ describe('pollUntilComplete', () => {
const errorMessage = 'error message';
beforeEach(() => {
- mock.onGet(endpoint).replyOnce(httpStatusCodes.NOT_FOUND, errorMessage);
+ mock.onGet(endpoint).replyOnce(HTTP_STATUS_NOT_FOUND, errorMessage);
});
it('rejects with the error response', () =>
@@ -78,7 +82,7 @@ describe('pollUntilComplete', () => {
describe('given params', () => {
const params = { foo: 'bar' };
beforeEach(() => {
- mock.onGet(endpoint, { params }).replyOnce(httpStatusCodes.OK, mockData);
+ mock.onGet(endpoint, { params }).replyOnce(HTTP_STATUS_OK, mockData);
});
it('requests the expected URL', () =>