fix: Update broken specs (#8651)

- Use fakeTimer for time.spec.js
- Use default sort as last_activity_at_desc
- Update specs for getAllConversations getter
This commit is contained in:
Pranav Raj S
2024-01-05 13:09:09 -08:00
committed by GitHub
parent 6e30064421
commit 2c7f93978e
4 changed files with 137 additions and 355 deletions

View File

@@ -1,5 +1,4 @@
import TimeMixin from '../time';
import { format } from 'date-fns';
describe('#messageStamp', () => {
it('returns correct value', () => {
@@ -11,10 +10,20 @@ describe('#messageStamp', () => {
});
describe('#messageTimestamp', () => {
beforeEach(() => {
jest.useFakeTimers('modern');
const mockDate = new Date(2023, 4, 5);
jest.setSystemTime(mockDate);
});
afterEach(() => {
jest.useRealTimers();
});
it('should return the message date in the specified format if the message was sent in the current year', () => {
const currentEpochTime = Math.floor(new Date().getTime() / 1000);
expect(TimeMixin.methods.messageTimestamp(currentEpochTime)).toEqual(
format(new Date(currentEpochTime * 1000), 'MMM d, yyyy')
expect(TimeMixin.methods.messageTimestamp(1680777464)).toEqual(
'Apr 6, 2023'
);
});
it('should return the message date and time in a different format if the message was sent in a different year', () => {