@@ -79,6 +79,22 @@ it('Does not apply the UTC mode by default', () => {
79
79
expect ( instance . minute ( ) ) . toEqual ( 34 )
80
80
} )
81
81
82
+ it ( 'Creates an UTC instance from another instance' , ( ) => {
83
+ const source = dayjs ( '2018-09-06' )
84
+ const instance = dayjs ( source , { utc : true } )
85
+ expect ( instance . $u ) . toBeTruthy ( )
86
+ expect ( instance . hour ( ) ) . toEqual ( source . toDate ( ) . getUTCHours ( ) )
87
+ expect ( instance . minute ( ) ) . toEqual ( source . toDate ( ) . getUTCMinutes ( ) )
88
+ } )
89
+
90
+ it ( 'Creating a new instance from another instance retains the UTC mode' , ( ) => {
91
+ const source = dayjs ( '2018-09-06' , { utc : true } )
92
+ const instance = dayjs ( source )
93
+ expect ( instance . $u ) . toBeTruthy ( )
94
+ expect ( instance . hour ( ) ) . toEqual ( source . hour ( ) )
95
+ expect ( instance . minute ( ) ) . toEqual ( source . minute ( ) )
96
+ } )
97
+
82
98
it ( 'Clone not affect each other' , ( ) => {
83
99
const base = dayjs ( 20170101 )
84
100
const year = base . year ( )
@@ -93,3 +109,9 @@ it('Clone with same value', () => {
93
109
const another = newBase . clone ( )
94
110
expect ( newBase . toString ( ) ) . toBe ( another . toString ( ) )
95
111
} )
112
+
113
+ it ( 'Clone retains the UTC mode' , ( ) => {
114
+ const instance = dayjs ( '2018-09-06' , { utc : true } )
115
+ const another = instance . clone ( )
116
+ expect ( another . $u ) . toBeTruthy ( )
117
+ } )
0 commit comments