Skip to content

Commit 1f51bb4

Browse files
committed
refactor: variables for common value
1 parent 287bc58 commit 1f51bb4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/metrics/tests/unit/Metrics.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,11 +2269,13 @@ describe('Class: Metrics', () => {
22692269

22702270
for (const { format, getTimestamp } of testCases) {
22712271
describe(`when timestamp is provided as ${format}`, () => {
2272+
const twoHours = 2 * 60 * 60 * 1000;
2273+
const fourteenDays = 14 * 24 * 60 * 60 * 1000;
2274+
22722275
test('should set the timestamp if provided in the future', () => {
22732276
// Prepare
22742277
const testMetric = 'test-metric';
22752278
const metrics: Metrics = new Metrics();
2276-
//Add 10 minutes to mockDate object and still remain as date object
22772279
const timestampMs = mockDate.getTime() + 10 * 60 * 1000; // Add 10 minutes in milliseconds
22782280

22792281
// Act
@@ -2315,7 +2317,7 @@ describe('Class: Metrics', () => {
23152317
test('should not log a warning if the timestamp exact two hours in the future and set the timestamp', () => {
23162318
// Prepare
23172319
const testMetric = 'test-metric';
2318-
const timestampMs = mockDate.getTime() + 2 * 60 * 60 * 1000; // Add 2 hours and 1 ms
2320+
const timestampMs = mockDate.getTime() + twoHours;
23192321
const customLogger = {
23202322
warn: jest.fn(),
23212323
debug: jest.fn(),
@@ -2344,7 +2346,7 @@ describe('Class: Metrics', () => {
23442346
test('should log a warning if the timestamp is more than two hours in the future but still set the timestamp', () => {
23452347
// Prepare
23462348
const testMetric = 'test-metric';
2347-
const timestampMs = mockDate.getTime() + 2 * 60 * 60 * 1000 + 1; // Add 2 hours and 1 ms
2349+
const timestampMs = mockDate.getTime() + twoHours + 1;
23482350
const customLogger = {
23492351
warn: jest.fn(),
23502352
debug: jest.fn(),
@@ -2376,7 +2378,7 @@ describe('Class: Metrics', () => {
23762378
test('should not log a warning if the timestamp is exact 14 days in the past and set the timestamp', () => {
23772379
// Prepare
23782380
const testMetric = 'test-metric';
2379-
const timestampMs = mockDate.getTime() - 14 * 24 * 60 * 60 * 1000; // Subtract 14 days
2381+
const timestampMs = mockDate.getTime() - fourteenDays;
23802382
const customLogger = {
23812383
warn: jest.fn(),
23822384
debug: jest.fn(),
@@ -2405,7 +2407,7 @@ describe('Class: Metrics', () => {
24052407
test('should log a warning if the timestamp is more than 14 days in the past but still set the timestamp', () => {
24062408
// Prepare
24072409
const testMetric = 'test-metric';
2408-
const timestampMs = mockDate.getTime() - 14 * 24 * 60 * 60 * 1000 - 1; // Subtract 14 days and 1 ms
2410+
const timestampMs = mockDate.getTime() - fourteenDays - 1;
24092411
const customLogger = {
24102412
warn: jest.fn(),
24112413
debug: jest.fn(),

0 commit comments

Comments
 (0)