@@ -13,60 +13,62 @@ component extends="coldbox.system.testing.BaseModelTest" model="cbsecurity.model
1313
1414 function run ( testResults , testBox ){
1515 describe ( " JwtService Epoch Conversion" , function (){
16-
1716 it ( " toEpoch returns correct epoch seconds for a known UTC date" , function (){
18- var utcNewYear = parseDateTime ( " 2024-01-01T00:00:00Z" );
17+ var utcNewYear = parseDateTime ( " 2024-01-01T00:00:00Z" );
1918 var epochSeconds = model .toEpoch ( utcNewYear );
2019 expect ( epochSeconds ).toBe ( 1704067200 );
2120 } );
2221
2322 it ( " fromEpoch returns a date that round-trips through toEpoch" , function (){
24- var now_ = now ();
23+ var now_ = now ();
2524 var epochSeconds = model .toEpoch ( now_ );
2625 var roundTripped = model .fromEpoch ( epochSeconds );
2726 expect ( dateDiff ( " s" , now_ , roundTripped ) ).toBeCloseTo ( 0 , 0 );
2827 } );
2928
3029 it ( " fromEpoch( 0 ) returns the epoch baseline" , function (){
31- var epochBaseline = model .fromEpoch ( 0 );
30+ var epochBaseline = model .fromEpoch ( 0 );
3231 var expectedBaseline = parseDateTime ( " 1970-01-01T00:00:00Z" );
3332 expect ( dateDiff ( " s" , epochBaseline , expectedBaseline ) ).toBe ( 0 );
3433 } );
3534
3635 it ( " toEpoch result is consistent with manual dateDiff calculation" , function (){
37- var testDate = now ();
36+ var testDate = now ();
3837 var toEpochResult = model .toEpoch ( testDate );
39- var manualEpoch = dateDiff ( " s" , parseDateTime ( " 1970-01-01T00:00:00Z" ), testDate );
38+ var manualEpoch = dateDiff (
39+ " s" ,
40+ parseDateTime ( " 1970-01-01T00:00:00Z" ),
41+ testDate
42+ );
4043 expect ( toEpochResult ).toBe ( manualEpoch );
4144 } );
4245
4346 it ( " toEpoch result is within acceptable range for current time" , function (){
44- var now_ = now ();
47+ var now_ = now ();
4548 var epochSeconds = model .toEpoch ( now_ );
4649 expect ( epochSeconds ).toBeGT ( 1700000000 );
4750 expect ( epochSeconds ).toBeLT ( 2000000000 );
4851 } );
4952
5053 it ( " toEpoch and fromEpoch handle epoch zero correctly" , function (){
51- var epochZero = 0 ;
54+ var epochZero = 0 ;
5255 var dateFromEpoch = model .fromEpoch ( epochZero );
53- var backToEpoch = model .toEpoch ( dateFromEpoch );
56+ var backToEpoch = model .toEpoch ( dateFromEpoch );
5457 expect ( backToEpoch ).toBe ( epochZero );
5558 } );
5659
5760 it ( " toEpoch handles dates before epoch (negative epoch)" , function (){
58- var beforeEpoch = parseDateTime ( " 1969-12-31T23:59:59Z" );
61+ var beforeEpoch = parseDateTime ( " 1969-12-31T23:59:59Z" );
5962 var epochSeconds = model .toEpoch ( beforeEpoch );
6063 expect ( epochSeconds ).toBe ( - 1 );
6164 } );
6265
6366 it ( " fromEpoch handles negative epoch values" , function (){
6467 var negativeEpoch = - 1 ;
6568 var dateFromEpoch = model .fromEpoch ( negativeEpoch );
66- var expectedDate = parseDateTime ( " 1969-12-31T23:59:59Z" );
69+ var expectedDate = parseDateTime ( " 1969-12-31T23:59:59Z" );
6770 expect ( dateDiff ( " s" , dateFromEpoch , expectedDate ) ).toBe ( 0 );
6871 } );
69-
7072 } );
7173 }
7274
0 commit comments