Skip to content

Commit

Permalink
feat(api): remove new date creation
Browse files Browse the repository at this point in the history
in extract timestamp request utils
  • Loading branch information
er-lim committed Mar 6, 2025
1 parent b69aa00 commit e3803e9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function extractLocaleFromRequest(request) {
}

function extractTimestampFromRequest(request) {
return request.info?.received ?? new Date().getTime();
return request.info.received;
}

export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
extractTimestampFromRequest,
extractUserIdFromRequest,
} from '../../../../../src/shared/infrastructure/utils/request-response-utils.js';
import { expect, generateAuthenticatedUserRequestHeaders, sinon } from '../../../../test-helper.js';
import { expect, generateAuthenticatedUserRequestHeaders } from '../../../../test-helper.js';

const { ENGLISH_SPOKEN, FRENCH_FRANCE, FRENCH_SPOKEN } = LOCALE;

Expand Down Expand Up @@ -101,29 +101,5 @@ describe('Unit | Utils | Request Utils', function () {
expect(timestamp).to.equal(startDateTimestamp);
});
});

context('when timestamp does not exist', function () {
let clock, now;

beforeEach(function () {
now = new Date('2023-09-12');
clock = sinon.useFakeTimers({ now, toFake: ['Date'] });
});

afterEach(function () {
clock.restore();
});

it('returns a new date in timestamp', function () {
// given
const request = {};

// when
const timestamp = extractTimestampFromRequest(request);

// then
expect(timestamp).to.equal(now.getTime());
});
});
});
});

0 comments on commit e3803e9

Please sign in to comment.