fix[parseTime]: fixed when pass null

5890499077
This commit is contained in:
潘嘉晨 2020-06-04 21:26:13 +08:00
parent aff349a863
commit 4a822b95d6
2 changed files with 5 additions and 1 deletions

View File

@ -9,7 +9,7 @@
* @returns {string | null}
*/
export function parseTime(time, cFormat) {
if (arguments.length === 0) {
if (arguments.length === 0 || !time) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'

View File

@ -28,4 +28,8 @@ describe('Utils:parseTime', () => {
it('empty argument', () => {
expect(parseTime()).toBeNull()
})
it('null', () => {
expect(parseTime(null)).toBeNull()
})
})