@@ -12,7 +12,14 @@ import assert from 'assert'
1212import * as path from 'path'
1313import * as vscode from 'vscode'
1414import sinon from 'sinon'
15- import { createAmazonQUri , getFileDiffUris , getOriginalFileUri , openDeletedDiff , openDiff } from '../../../amazonq'
15+ import {
16+ createAmazonQUri ,
17+ getFileDiffUris ,
18+ getOriginalFileUri ,
19+ openDeletedDiff ,
20+ openDiff ,
21+ openFile ,
22+ } from '../../../amazonq'
1623import { FileSystem } from '../../../shared/fs/fs'
1724
1825describe ( 'diff' , ( ) => {
@@ -60,16 +67,18 @@ describe('diff', () => {
6067 sandbox . stub ( FileSystem . prototype , 'exists' ) . resolves ( true )
6168 await openDeletedDiff ( filePath , name , tabId )
6269
63- const expectedPath = vscode . Uri . file ( filePath )
64- assert . ok ( executeCommandSpy . calledWith ( 'vscode.diff' , expectedPath , expectedPath , `${ name } (Deleted)` ) )
70+ const leftExpected = vscode . Uri . file ( filePath )
71+ const rightExpected = createAmazonQUri ( 'empty' , tabId )
72+ assert . ok ( executeCommandSpy . calledWith ( 'vscode.diff' , leftExpected , rightExpected , `${ name } (Deleted)` ) )
6573 } )
6674
6775 it ( 'file does not exists locally' , async ( ) => {
6876 sandbox . stub ( FileSystem . prototype , 'exists' ) . resolves ( false )
6977 await openDeletedDiff ( filePath , name , tabId )
7078
71- const expectedPath = createAmazonQUri ( 'empty' , tabId )
72- assert . ok ( executeCommandSpy . calledWith ( 'vscode.open' , expectedPath , expectedPath , `${ name } (Deleted)` ) )
79+ const leftExpected = createAmazonQUri ( 'empty' , tabId )
80+ const rightExpected = createAmazonQUri ( 'empty' , tabId )
81+ assert . ok ( executeCommandSpy . calledWith ( 'vscode.diff' , leftExpected , rightExpected , `${ name } (Deleted)` ) )
7382 } )
7483 } )
7584
@@ -110,4 +119,21 @@ describe('diff', () => {
110119 assert . deepStrictEqual ( right , rightExpected )
111120 } )
112121 } )
122+
123+ describe ( 'openFile' , ( ) => {
124+ it ( 'file exists locally' , async ( ) => {
125+ sandbox . stub ( FileSystem . prototype , 'exists' ) . resolves ( true )
126+ await openFile ( filePath )
127+
128+ const expected = vscode . Uri . file ( filePath )
129+ assert . ok ( executeCommandSpy . calledWith ( 'vscode.diff' , expected , expected ) )
130+ } )
131+
132+ it ( 'file does not exists locally' , async ( ) => {
133+ sandbox . stub ( FileSystem . prototype , 'exists' ) . resolves ( false )
134+ await openFile ( filePath )
135+
136+ assert . ok ( executeCommandSpy . notCalled )
137+ } )
138+ } )
113139} )
0 commit comments