chore: 提交剩余开发改动
包含商务通消息映射、会话时间与未读状态、前端消息展示、数据库修复迁移、测试覆盖备份及 Captain 设计文档。
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
getDayDifferenceFromNow,
|
||||
hasOneDayPassed,
|
||||
} from 'shared/helpers/timeHelper';
|
||||
import { zhCN } from 'date-fns/locale';
|
||||
|
||||
beforeEach(() => {
|
||||
process.env.TZ = 'UTC';
|
||||
@@ -35,12 +36,27 @@ describe('#messageTimestamp', () => {
|
||||
it('should return the message date and time in a different format if the message was sent in a different year', () => {
|
||||
expect(messageTimestamp(1612971343)).toEqual('Feb 10 2021, 3:35 PM');
|
||||
});
|
||||
it('supports Chinese message time formats for current and previous years', () => {
|
||||
expect(
|
||||
messageTimestamp(1680777464, 'M月d日 aaa h:mm', {
|
||||
locale: zhCN,
|
||||
fallbackFormat: 'yyyy年M月d日 aaa h:mm',
|
||||
})
|
||||
).toEqual('4月6日 上午 10:37');
|
||||
expect(
|
||||
messageTimestamp(1612971343, 'M月d日 aaa h:mm', {
|
||||
locale: zhCN,
|
||||
fallbackFormat: 'yyyy年M月d日 aaa h:mm',
|
||||
})
|
||||
).toEqual('2021年2月10日 下午 3:35');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#dynamicTime', () => {
|
||||
it('returns correct value', () => {
|
||||
Date.now = vi.fn(() => new Date(Date.UTC(2023, 1, 14)).valueOf());
|
||||
expect(dynamicTime(1612971343)).toEqual('about 2 years ago');
|
||||
expect(dynamicTime(1612971343, { locale: zhCN })).toEqual('大约 2 年前');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -48,6 +64,9 @@ describe('#dateFormat', () => {
|
||||
it('returns correct value', () => {
|
||||
expect(dateFormat(1612971343)).toEqual('Feb 10, 2021');
|
||||
expect(dateFormat(1612971343, 'LLL d, yyyy')).toEqual('Feb 10, 2021');
|
||||
expect(dateFormat(1612971343, 'yyyy年M月d日', { locale: zhCN })).toEqual(
|
||||
'2021年2月10日'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user