File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
apps/evm/src/App/ChainUpgradeHandler/__tests__ Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ import { renderComponent } from 'testUtils/render' ;
2+
3+ import { ChainUpgradeHandler } from 'App/ChainUpgradeHandler' ;
4+ import type { MockInstance } from 'vitest' ;
5+
6+ const runtimeTimestamp = new Date ( ) . getTime ( ) ;
7+ const upgradeTimestamps = [ new Date ( runtimeTimestamp + 2000 ) ] ;
8+ const fakeNowMs = runtimeTimestamp + 12000 ;
9+
10+ describe ( 'ChainUpgradeHandler' , ( ) => {
11+ let reloadSpy : MockInstance ;
12+
13+ beforeEach ( ( ) => {
14+ // 1. Redefine the 'reload' property on window.location to be configurable.
15+ // This is necessary because it is non-configurable by default in jsdom.
16+ Object . defineProperty ( window , 'location' , {
17+ configurable : true ,
18+ value : ( ) => { } , // Provide a dummy function initially
19+ } ) ;
20+
21+ Object . defineProperty ( window . location , 'reload' , {
22+ configurable : true ,
23+ value : ( ) => { } , // Provide a dummy function initially
24+ } ) ;
25+
26+ // 2. Create the spy on the now-configurable property.
27+ reloadSpy = vi . spyOn ( window . location , 'reload' ) ;
28+ } ) ;
29+
30+ it ( 'auto reload after passing hardforks' , ( ) => {
31+ vi . useFakeTimers ( ) . setSystemTime ( new Date ( fakeNowMs ) ) ;
32+
33+ renderComponent ( < ChainUpgradeHandler upgradeTimestamps = { upgradeTimestamps } /> ) ;
34+
35+ expect ( reloadSpy ) . toHaveBeenCalled ( ) ;
36+ } ) ;
37+ } ) ;
You can’t perform that action at this time.
0 commit comments