@@ -5812,12 +5812,21 @@ describe('DataSource', () => {
58125812
58135813 it ( 'Should launch the interactive rebase of the current branch on a branch in a terminal' , async ( ) => {
58145814 // Setup
5815+ jest . useFakeTimers ( ) ;
58155816 const spyOnOpenGitTerminal = jest . spyOn ( utils , 'openGitTerminal' ) ;
58165817 spyOnOpenGitTerminal . mockReturnValueOnce ( ) ;
58175818 vscode . mockExtensionSettingReturnValue ( 'repository.sign.commits' , false ) ;
58185819
58195820 // Run
5820- const result = await dataSource . rebase ( '/path/to/repo' , 'develop' , RebaseActionOn . Branch , false , true ) ;
5821+ const resultPromise = dataSource . rebase ( '/path/to/repo' , 'develop' , RebaseActionOn . Branch , false , true ) ;
5822+
5823+ // Assert
5824+ expect ( setTimeout ) . toHaveBeenCalledWith ( expect . anything ( ) , 1000 ) ;
5825+
5826+ // Run
5827+ jest . runOnlyPendingTimers ( ) ;
5828+ jest . useRealTimers ( ) ;
5829+ const result = await resultPromise ;
58215830
58225831 // Assert
58235832 expect ( result ) . toBe ( null ) ;
@@ -5826,12 +5835,21 @@ describe('DataSource', () => {
58265835
58275836 it ( 'Should launch the interactive rebase of the current branch on a commit in a terminal' , async ( ) => {
58285837 // Setup
5838+ jest . useFakeTimers ( ) ;
58295839 const spyOnOpenGitTerminal = jest . spyOn ( utils , 'openGitTerminal' ) ;
58305840 spyOnOpenGitTerminal . mockReturnValueOnce ( ) ;
58315841 vscode . mockExtensionSettingReturnValue ( 'repository.sign.commits' , false ) ;
58325842
58335843 // Run
5834- const result = await dataSource . rebase ( '/path/to/repo' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , RebaseActionOn . Commit , false , true ) ;
5844+ const resultPromise = dataSource . rebase ( '/path/to/repo' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , RebaseActionOn . Commit , false , true ) ;
5845+
5846+ // Assert
5847+ expect ( setTimeout ) . toHaveBeenCalledWith ( expect . anything ( ) , 1000 ) ;
5848+
5849+ // Run
5850+ jest . runOnlyPendingTimers ( ) ;
5851+ jest . useRealTimers ( ) ;
5852+ const result = await resultPromise ;
58355853
58365854 // Assert
58375855 expect ( result ) . toBe ( null ) ;
@@ -5840,12 +5858,21 @@ describe('DataSource', () => {
58405858
58415859 it ( 'Should launch the interactive rebase of the current branch on a branch in a terminal (signing the new commits)' , async ( ) => {
58425860 // Setup
5861+ jest . useFakeTimers ( ) ;
58435862 const spyOnOpenGitTerminal = jest . spyOn ( utils , 'openGitTerminal' ) ;
58445863 spyOnOpenGitTerminal . mockReturnValueOnce ( ) ;
58455864 vscode . mockExtensionSettingReturnValue ( 'repository.sign.commits' , true ) ;
58465865
58475866 // Run
5848- const result = await dataSource . rebase ( '/path/to/repo' , 'develop' , RebaseActionOn . Branch , false , true ) ;
5867+ const resultPromise = dataSource . rebase ( '/path/to/repo' , 'develop' , RebaseActionOn . Branch , false , true ) ;
5868+
5869+ // Assert
5870+ expect ( setTimeout ) . toHaveBeenCalledWith ( expect . anything ( ) , 1000 ) ;
5871+
5872+ // Run
5873+ jest . runOnlyPendingTimers ( ) ;
5874+ jest . useRealTimers ( ) ;
5875+ const result = await resultPromise ;
58495876
58505877 // Assert
58515878 expect ( result ) . toBe ( null ) ;
@@ -6484,10 +6511,19 @@ describe('DataSource', () => {
64846511 describe ( 'openExternalDirDiff' , ( ) => {
64856512 it ( 'Should launch a gui directory diff (for one commit)' , async ( ) => {
64866513 // Setup
6514+ jest . useFakeTimers ( ) ;
64876515 mockGitSuccessOnce ( ) ;
64886516
64896517 // Run
6490- const result = await dataSource . openExternalDirDiff ( '/path/to/repo' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , true ) ;
6518+ const resultPromise = dataSource . openExternalDirDiff ( '/path/to/repo' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , true ) ;
6519+
6520+ // Assert
6521+ expect ( setTimeout ) . toHaveBeenCalledWith ( expect . anything ( ) , 1500 ) ;
6522+
6523+ // Run
6524+ jest . runOnlyPendingTimers ( ) ;
6525+ jest . useRealTimers ( ) ;
6526+ const result = await resultPromise ;
64916527
64926528 // Assert
64936529 expect ( result ) . toBe ( null ) ;
@@ -6498,10 +6534,19 @@ describe('DataSource', () => {
64986534
64996535 it ( 'Should launch a gui directory diff (between two commits)' , async ( ) => {
65006536 // Setup
6537+ jest . useFakeTimers ( ) ;
65016538 mockGitSuccessOnce ( ) ;
65026539
65036540 // Run
6504- const result = await dataSource . openExternalDirDiff ( '/path/to/repo' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , '2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c' , true ) ;
6541+ const resultPromise = dataSource . openExternalDirDiff ( '/path/to/repo' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , '2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c' , true ) ;
6542+
6543+ // Assert
6544+ expect ( setTimeout ) . toHaveBeenCalledWith ( expect . anything ( ) , 1500 ) ;
6545+
6546+ // Run
6547+ jest . runOnlyPendingTimers ( ) ;
6548+ jest . useRealTimers ( ) ;
6549+ const result = await resultPromise ;
65056550
65066551 // Assert
65076552 expect ( result ) . toBe ( null ) ;
@@ -6512,10 +6557,19 @@ describe('DataSource', () => {
65126557
65136558 it ( 'Should launch a gui directory diff (for uncommitted changes)' , async ( ) => {
65146559 // Setup
6560+ jest . useFakeTimers ( ) ;
65156561 mockGitSuccessOnce ( ) ;
65166562
65176563 // Run
6518- const result = await dataSource . openExternalDirDiff ( '/path/to/repo' , utils . UNCOMMITTED , utils . UNCOMMITTED , true ) ;
6564+ const resultPromise = dataSource . openExternalDirDiff ( '/path/to/repo' , utils . UNCOMMITTED , utils . UNCOMMITTED , true ) ;
6565+
6566+ // Assert
6567+ expect ( setTimeout ) . toHaveBeenCalledWith ( expect . anything ( ) , 1500 ) ;
6568+
6569+ // Run
6570+ jest . runOnlyPendingTimers ( ) ;
6571+ jest . useRealTimers ( ) ;
6572+ const result = await resultPromise ;
65196573
65206574 // Assert
65216575 expect ( result ) . toBe ( null ) ;
@@ -6526,10 +6580,19 @@ describe('DataSource', () => {
65266580
65276581 it ( 'Should launch a gui directory diff (between a commit and the uncommitted changes)' , async ( ) => {
65286582 // Setup
6583+ jest . useFakeTimers ( ) ;
65296584 mockGitSuccessOnce ( ) ;
65306585
65316586 // Run
6532- const result = await dataSource . openExternalDirDiff ( '/path/to/repo' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , utils . UNCOMMITTED , true ) ;
6587+ const resultPromise = dataSource . openExternalDirDiff ( '/path/to/repo' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , utils . UNCOMMITTED , true ) ;
6588+
6589+ // Assert
6590+ expect ( setTimeout ) . toHaveBeenCalledWith ( expect . anything ( ) , 1500 ) ;
6591+
6592+ // Run
6593+ jest . runOnlyPendingTimers ( ) ;
6594+ jest . useRealTimers ( ) ;
6595+ const result = await resultPromise ;
65336596
65346597 // Assert
65356598 expect ( result ) . toBe ( null ) ;
@@ -6540,11 +6603,20 @@ describe('DataSource', () => {
65406603
65416604 it ( 'Should launch a directory diff in a terminal (between two commits)' , async ( ) => {
65426605 // Setup
6606+ jest . useFakeTimers ( ) ;
65436607 const spyOnOpenGitTerminal = jest . spyOn ( utils , 'openGitTerminal' ) ;
65446608 spyOnOpenGitTerminal . mockReturnValueOnce ( ) ;
65456609
65466610 // Run
6547- const result = await dataSource . openExternalDirDiff ( '/path/to/repo' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , '2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c' , false ) ;
6611+ const resultPromise = dataSource . openExternalDirDiff ( '/path/to/repo' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , '2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c' , false ) ;
6612+
6613+ // Assert
6614+ expect ( setTimeout ) . toHaveBeenCalledWith ( expect . anything ( ) , 1500 ) ;
6615+
6616+ // Run
6617+ jest . runOnlyPendingTimers ( ) ;
6618+ jest . useRealTimers ( ) ;
6619+ const result = await resultPromise ;
65486620
65496621 // Assert
65506622 expect ( result ) . toBe ( null ) ;
@@ -6565,11 +6637,20 @@ describe('DataSource', () => {
65656637
65666638 it ( 'Should display the error message when the diff tool doesn\'t exit successfully' , async ( ) => {
65676639 // Setup
6640+ jest . useFakeTimers ( ) ;
65686641 mockGitThrowingErrorOnce ( 'line1\nline2\nline3' ) ;
65696642 vscode . window . showErrorMessage . mockResolvedValueOnce ( null ) ;
65706643
65716644 // Run
6572- const result = await dataSource . openExternalDirDiff ( '/path/to/repo' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , utils . UNCOMMITTED , true ) ;
6645+ const resultPromise = dataSource . openExternalDirDiff ( '/path/to/repo' , '1a2b3c4d5e6f1a2b3c4d5e6f1a2b3c4d5e6f1a2b' , utils . UNCOMMITTED , true ) ;
6646+
6647+ // Assert
6648+ expect ( setTimeout ) . toHaveBeenCalledWith ( expect . anything ( ) , 1500 ) ;
6649+
6650+ // Run
6651+ jest . runOnlyPendingTimers ( ) ;
6652+ jest . useRealTimers ( ) ;
6653+ const result = await resultPromise ;
65736654
65746655 // Assert
65756656 expect ( result ) . toBe ( null ) ;
0 commit comments