File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 1515 */
1616
1717import { expect } from 'chai' ;
18- import { ChronoUnit } from 'js-joda' ;
18+ import { ChronoUnit , Instant , LocalDateTime , ZoneId } from 'js-joda' ;
1919import { Deadline } from '../../../src/model/transaction/Deadline' ;
2020
2121describe ( 'Deadline' , ( ) => {
2222 it ( 'should createComplete timestamp today' , ( ) => {
2323 const deadline = Deadline . create ( ) ;
24- const date = new Date ( ) ;
25- expect ( deadline . value . dayOfMonth ( ) ) . to . be . equal ( date . getDate ( ) ) ;
26- expect ( deadline . value . monthValue ( ) ) . to . be . equal ( date . getMonth ( ) + 1 ) ;
27- expect ( deadline . value . year ( ) ) . to . be . equal ( date . getFullYear ( ) ) ;
24+
25+ // avoid SYSTEM and UTC differences
26+ const networkTimeStamp = ( new Date ( ) ) . getTime ( ) ;
27+ const timestampLocal = LocalDateTime . ofInstant ( Instant . ofEpochMilli ( networkTimeStamp ) , ZoneId . SYSTEM ) ;
28+ const reproducedDate = timestampLocal . plus ( 2 , ChronoUnit . HOURS ) ;
29+
30+ expect ( deadline . value . dayOfMonth ( ) ) . to . be . equal ( reproducedDate . dayOfMonth ( ) ) ;
31+ expect ( deadline . value . monthValue ( ) ) . to . be . equal ( reproducedDate . monthValue ( ) ) ;
32+ expect ( deadline . value . year ( ) ) . to . be . equal ( reproducedDate . year ( ) ) ;
2833 } ) ;
2934
3035 it ( 'should throw error deadline smaller than timeStamp' , ( ) => {
You can’t perform that action at this time.
0 commit comments