diff --git a/tests/unit/.eslintrc.js b/tests/unit/.eslintrc.js index 013a195..958d51b 100644 --- a/tests/unit/.eslintrc.js +++ b/tests/unit/.eslintrc.js @@ -2,4 +2,4 @@ module.exports = { env: { jest: true } -} \ No newline at end of file +} diff --git a/tests/unit/utils/formatTime.spec.js b/tests/unit/utils/formatTime.spec.js index 3804119..d07e414 100644 --- a/tests/unit/utils/formatTime.spec.js +++ b/tests/unit/utils/formatTime.spec.js @@ -1,6 +1,8 @@ import { formatTime } from '@/utils/index.js' describe('Utils:formatTime', () => { const d = new Date('2018-07-13 17:54:01') // "2018-07-13 17:54:01" + const retrofit = 5 * 1000 + it('ten digits timestamp', () => { expect(formatTime((d / 1000).toFixed(0))).toBe('7月13日17时54分') }) @@ -8,10 +10,10 @@ describe('Utils:formatTime', () => { expect(formatTime(+new Date() - 1)).toBe('刚刚') }) it('less two minute', () => { - expect(formatTime(+new Date() - 60 * 2 * 1000)).toBe('2分钟前') + expect(formatTime(+new Date() - 60 * 2 * 1000 + retrofit)).toBe('2分钟前') }) it('less two hour', () => { - expect(formatTime(+new Date() - 60 * 60 * 2 * 1000)).toBe('2小时前') + expect(formatTime(+new Date() - 60 * 60 * 2 * 1000 + retrofit)).toBe('2小时前') }) it('less one day', () => { expect(formatTime(+new Date() - 60 * 60 * 24 * 1 * 1000)).toBe('1天前')