Commit 368108b 1 parent 48cbf31 commit 368108b Copy full SHA for 368108b
File tree 2 files changed +17
-6
lines changed
2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 1
1
export default ( o , c , d ) => {
2
2
const sortBy = ( method , dates ) => {
3
- if ( ! dates . length ) {
4
- return d ( )
3
+ if ( ! dates || ! dates . length || ! dates [ 0 ] || ( dates . length === 1 && ! dates [ 0 ] . length ) ) {
4
+ return null
5
5
}
6
6
if ( dates . length === 1 && dates [ 0 ] . length > 0 ) {
7
7
[ dates ] = dates
Original file line number Diff line number Diff line change @@ -18,10 +18,21 @@ const arg3 = dayjs('2017-01-01')
18
18
const arg4 = dayjs ( 'Invalid Date' )
19
19
20
20
it ( 'Return current time if no argument' , ( ) => {
21
- expect ( dayjs . max ( ) . format ( ) )
22
- . toBe ( dayjs ( ) . format ( ) )
23
- expect ( dayjs . min ( ) . format ( ) )
24
- . toBe ( dayjs ( ) . format ( ) )
21
+ expect ( dayjs . max ( ) )
22
+ . toBe ( null )
23
+ expect ( dayjs . min ( ) )
24
+ . toBe ( null )
25
+ expect ( dayjs . max ( null ) )
26
+ . toBe ( null )
27
+ expect ( dayjs . min ( null ) )
28
+ . toBe ( null )
29
+ } )
30
+
31
+ it ( 'Return current time if passing empty array' , ( ) => {
32
+ expect ( dayjs . max ( [ ] ) )
33
+ . toBe ( null )
34
+ expect ( dayjs . min ( [ ] ) )
35
+ . toBe ( null )
25
36
} )
26
37
27
38
it ( 'Compare between arguments' , ( ) => {
You can’t perform that action at this time.
0 commit comments