fix[parseTime]: fixed when pass null (#3038)
This commit is contained in:
parent
29b4ff636b
commit
5890499077
|
@ -9,7 +9,7 @@
|
||||||
* @returns {string | null}
|
* @returns {string | null}
|
||||||
*/
|
*/
|
||||||
export function parseTime(time, cFormat) {
|
export function parseTime(time, cFormat) {
|
||||||
if (arguments.length === 0) {
|
if (arguments.length === 0 || !time) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
|
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { parseTime } from '@/utils/index.js'
|
import { parseTime } from '@/utils/index.js'
|
||||||
|
|
||||||
describe('Utils:parseTime', () => {
|
describe('Utils:parseTime', () => {
|
||||||
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"
|
||||||
it('timestamp', () => {
|
it('timestamp', () => {
|
||||||
|
@ -29,4 +30,8 @@ describe('Utils:parseTime', () => {
|
||||||
it('empty argument', () => {
|
it('empty argument', () => {
|
||||||
expect(parseTime()).toBeNull()
|
expect(parseTime()).toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('null', () => {
|
||||||
|
expect(parseTime(null)).toBeNull()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue