File tree Expand file tree Collapse file tree
apps/web/src/components/onboarding Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -230,8 +230,9 @@ async function mountImport(remote = false) {
230230}
231231
232232// The mocked modules read `state`, so every test starts by replacing all of it.
233+ // Returns the clock spy so each test can `using` it; the spy would otherwise outlive the test.
233234function setup ( ) {
234- vi . spyOn ( Date , "now" ) . mockReturnValue ( NOW ) ;
235+ const now = vi . spyOn ( Date , "now" ) . mockReturnValue ( NOW ) ;
235236 state . sessions . clear ( ) ;
236237 for ( const id of [ primaryId , remoteId ] ) {
237238 state . sessions . set (
@@ -257,10 +258,11 @@ function setup() {
257258 state . onDone . mockReset ( ) ;
258259 state . scan . mockReset ( ) ;
259260 state . refreshScan . mockReset ( ) ;
261+ return now ;
260262}
261263
262264it ( "rechecks after project creation and can retry its history without recreating the project" , async ( ) => {
263- setup ( ) ;
265+ using _now = setup ( ) ;
264266 const creation = deferred < void > ( ) ;
265267 state . createProject . mockImplementationOnce ( async ( input : CreateProjectInput ) => {
266268 await creation . promise ;
@@ -287,7 +289,7 @@ it("rechecks after project creation and can retry its history without recreating
287289} ) ;
288290
289291it ( "completes accepted imports when permission is revoked after the final server write" , async ( ) => {
290- setup ( ) ;
292+ using _now = setup ( ) ;
291293 state . candidates = state . candidates . slice ( 0 , 1 ) ;
292294 const imported = deferred < { importedCount : number ; skippedCount : number } > ( ) ;
293295 state . importThreads . mockImplementationOnce ( async ( ) =>
You can’t perform that action at this time.
0 commit comments