@@ -35,6 +35,9 @@ import {
3535} from "../utils/testUtils"
3636
3737describe ( "Unit test for overall task validation" , ( ) => {
38+ beforeEach ( ( ) => {
39+ jest . useFakeTimers ( ) . setSystemTime ( DEFAULT_DATE )
40+ } )
3841 it ( "When task is valid, should return true with no issues." , async ( ) => {
3942 const expectedOutcome = { valid : true , issues : undefined }
4043 const entry : BundleEntry = { fullUrl : FULL_URL_0 , resource : validTask ( ) }
@@ -141,9 +144,6 @@ describe("Unit tests for pre-cast validation of bundle", () => {
141144} )
142145
143146describe ( "Unit tests for validation of lastModified" , ( ) => {
144- beforeEach ( ( ) => {
145- jest . useFakeTimers ( ) . setSystemTime ( DEFAULT_DATE )
146- } )
147147
148148 it ( "When lastModified is over a day in the future, should return expected issue." , async ( ) => {
149149 const futureDate = new Date (
@@ -175,12 +175,33 @@ describe("Unit tests for validation of lastModified", () => {
175175
176176 expect ( actual ) . toEqual ( undefined )
177177 } )
178+
179+ it ( "When meta.lastUpdated present, lastModified <= 999 hours into future should be valid." , async ( ) => {
180+ const withinWindow = new Date (
181+ DEFAULT_DATE . valueOf ( ) - ( 998 * 60 * 60 * 1000 )
182+ )
183+ const task = { lastModified : withinWindow . toISOString ( ) , meta : { lastUpdated : DEFAULT_DATE . toISOString ( ) } }
184+
185+ const actual = lastModified ( task as Task )
186+
187+ expect ( actual ) . toEqual ( undefined )
188+ } )
189+
190+ it ( "When meta.lastUpdated present, lastModified > 999 hours into future should return expected issue." , async ( ) => {
191+ const futureDate = new Date (
192+ DEFAULT_DATE . valueOf ( ) + ( 999 * 60 * 60 * 1000 + 1000 )
193+ )
194+ const task = { lastModified : futureDate . toISOString ( ) , meta : { lastUpdated : DEFAULT_DATE . toISOString ( ) } }
195+
196+ const expected = "Invalid lastModified value provided."
197+
198+ const actual = lastModified ( task as Task )
199+
200+ expect ( actual ) . toEqual ( expected )
201+ } )
178202} )
179203
180204describe ( "Unit tests for validation of metaLastUpdated" , ( ) => {
181- beforeEach ( ( ) => {
182- jest . useFakeTimers ( ) . setSystemTime ( DEFAULT_DATE )
183- } )
184205
185206 it ( "When meta.lastUpdated is over a day in the future, should return expected issue." , async ( ) => {
186207 const futureDate = new Date (
0 commit comments