THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

fix[parseTime]: fixed when pass null (#3038)

pull/3164/head
cooper 5 months ago
committed by GitHub
parent
commit
5890499077
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions
  1. +1
    -1
      src/utils/index.js
  2. +5
    -0
      tests/unit/utils/parseTime.spec.js

+ 1
- 1
src/utils/index.js 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}'

+ 5
- 0
tests/unit/utils/parseTime.spec.js View File

@ -1,4 +1,5 @@
import { parseTime } from '@/utils/index.js'
describe('Utils:parseTime', () => {
const d = new Date('2018-07-13 17:54:01') // "2018-07-13 17:54:01"
it('timestamp', () => {
@ -29,4 +30,8 @@ describe('Utils:parseTime', () => {
it('empty argument', () => {
expect(parseTime()).toBeNull()
})
it('null', () => {
expect(parseTime(null)).toBeNull()
})
})

Loading…
Cancel
Save