From 8a8f325f64c00caa8538e29a990ff4c671937436 Mon Sep 17 00:00:00 2001 From: Vishnu Narayanan Date: Fri, 5 Jan 2024 12:36:26 +0530 Subject: [PATCH] fix: messageTimestamp test (#8644) --- app/javascript/dashboard/mixins/specs/time.spec.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/javascript/dashboard/mixins/specs/time.spec.js b/app/javascript/dashboard/mixins/specs/time.spec.js index b1cd46d3126c..160cc9ff81da 100644 --- a/app/javascript/dashboard/mixins/specs/time.spec.js +++ b/app/javascript/dashboard/mixins/specs/time.spec.js @@ -1,4 +1,5 @@ import TimeMixin from '../time'; +import { format } from 'date-fns'; describe('#messageStamp', () => { it('returns correct value', () => { @@ -11,8 +12,9 @@ describe('#messageStamp', () => { describe('#messageTimestamp', () => { it('should return the message date in the specified format if the message was sent in the current year', () => { - expect(TimeMixin.methods.messageTimestamp(1680777464)).toEqual( - 'Apr 6, 2023' + const currentEpochTime = Math.floor(new Date().getTime() / 1000); + expect(TimeMixin.methods.messageTimestamp(currentEpochTime)).toEqual( + format(new Date(currentEpochTime * 1000), 'MMM d, yyyy') ); }); it('should return the message date and time in a different format if the message was sent in a different year', () => {