diff --git a/src/plugin/minMax/index.js b/src/plugin/minMax/index.js index d96d0568..f515c60d 100644 --- a/src/plugin/minMax/index.js +++ b/src/plugin/minMax/index.js @@ -1,7 +1,7 @@ export default (o, c, d) => { const sortBy = (method, dates) => { - if (!dates.length) { - return d() + if (!dates || !dates.length || !dates[0] || (dates.length === 1 && !dates[0].length)) { + return null } if (dates.length === 1 && dates[0].length > 0) { [dates] = dates diff --git a/test/plugin/minMax.test.js b/test/plugin/minMax.test.js index 7cc9db92..eeef9206 100644 --- a/test/plugin/minMax.test.js +++ b/test/plugin/minMax.test.js @@ -18,10 +18,21 @@ const arg3 = dayjs('2017-01-01') const arg4 = dayjs('Invalid Date') it('Return current time if no argument', () => { - expect(dayjs.max().format()) - .toBe(dayjs().format()) - expect(dayjs.min().format()) - .toBe(dayjs().format()) + expect(dayjs.max()) + .toBe(null) + expect(dayjs.min()) + .toBe(null) + expect(dayjs.max(null)) + .toBe(null) + expect(dayjs.min(null)) + .toBe(null) +}) + +it('Return current time if passing empty array', () => { + expect(dayjs.max([])) + .toBe(null) + expect(dayjs.min([])) + .toBe(null) }) it('Compare between arguments', () => {