refine test
parent
065c5e9635
commit
0caf5580ac
|
@ -2,4 +2,4 @@ module.exports = {
|
||||||
env: {
|
env: {
|
||||||
jest: true
|
jest: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import { formatTime } from '@/utils/index.js'
|
import { formatTime } from '@/utils/index.js'
|
||||||
describe('Utils:formatTime', () => {
|
describe('Utils:formatTime', () => {
|
||||||
const d = new Date('2018-07-13 17:54:01') // "2018-07-13 17:54:01"
|
const d = new Date('2018-07-13 17:54:01') // "2018-07-13 17:54:01"
|
||||||
|
const retrofit = 5 * 1000
|
||||||
|
|
||||||
it('ten digits timestamp', () => {
|
it('ten digits timestamp', () => {
|
||||||
expect(formatTime((d / 1000).toFixed(0))).toBe('7月13日17时54分')
|
expect(formatTime((d / 1000).toFixed(0))).toBe('7月13日17时54分')
|
||||||
})
|
})
|
||||||
|
@ -8,10 +10,10 @@ describe('Utils:formatTime', () => {
|
||||||
expect(formatTime(+new Date() - 1)).toBe('刚刚')
|
expect(formatTime(+new Date() - 1)).toBe('刚刚')
|
||||||
})
|
})
|
||||||
it('less two minute', () => {
|
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', () => {
|
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', () => {
|
it('less one day', () => {
|
||||||
expect(formatTime(+new Date() - 60 * 60 * 24 * 1 * 1000)).toBe('1天前')
|
expect(formatTime(+new Date() - 60 * 60 * 24 * 1 * 1000)).toBe('1天前')
|
||||||
|
|
Loading…
Reference in New Issue