@@ -79,6 +79,22 @@ it('Does not apply the UTC mode by default', () => {
7979 expect ( instance . minute ( ) ) . toEqual ( 34 )
8080} )
8181
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+
8298it ( 'Clone not affect each other' , ( ) => {
8399 const base = dayjs ( 20170101 )
84100 const year = base . year ( )
@@ -93,3 +109,9 @@ it('Clone with same value', () => {
93109 const another = newBase . clone ( )
94110 expect ( newBase . toString ( ) ) . toBe ( another . toString ( ) )
95111} )
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