1111import assert from 'assert'
1212import * as path from 'path'
1313import * as vscode from 'vscode'
14- import fs from 'fs'
1514import sinon from 'sinon'
1615import { createAmazonQUri , getFileDiffUris , getOriginalFileUri , openDeletedDiff , openDiff } from '../../../amazonq'
1716import { FileSystem } from '../../../shared/fs/fs'
@@ -36,7 +35,7 @@ describe('diff', () => {
3635
3736 describe ( 'openDiff' , ( ) => {
3837 it ( 'file exists locally' , async ( ) => {
39- sandbox . stub ( fs , 'existsSync ' ) . returns ( true )
38+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( true )
4039 await openDiff ( filePath , rightPath , tabId )
4140
4241 const leftExpected = vscode . Uri . file ( filePath )
@@ -45,10 +44,10 @@ describe('diff', () => {
4544 } )
4645
4746 it ( 'file does not exists locally' , async ( ) => {
48- sandbox . stub ( fs , 'existsSync ' ) . returns ( false )
47+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( false )
4948 await openDiff ( filePath , rightPath , tabId )
5049
51- const leftExpected = getOriginalFileUri ( filePath , tabId )
50+ const leftExpected = await getOriginalFileUri ( filePath , tabId )
5251 const rightExpected = createAmazonQUri ( rightPath , tabId )
5352 assert . ok ( executeCommandSpy . calledWith ( 'vscode.diff' , leftExpected , rightExpected ) )
5453 } )
@@ -76,20 +75,20 @@ describe('diff', () => {
7675
7776 describe ( 'getOriginalFileUri' , ( ) => {
7877 it ( 'file exists locally' , async ( ) => {
79- sandbox . stub ( fs , 'existsSync ' ) . returns ( true )
78+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( true )
8079 assert . deepStrictEqual ( ( await getOriginalFileUri ( filePath , tabId ) ) . fsPath , filePath )
8180 } )
8281
83- it ( 'file does not exists locally' , ( ) => {
84- sandbox . stub ( fs , 'existsSync ' ) . returns ( false )
82+ it ( 'file does not exists locally' , async ( ) => {
83+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( false )
8584 const expected = createAmazonQUri ( 'empty' , tabId )
86- assert . deepStrictEqual ( getOriginalFileUri ( filePath , tabId ) , expected )
85+ assert . deepStrictEqual ( await getOriginalFileUri ( filePath , tabId ) , expected )
8786 } )
8887 } )
8988
9089 describe ( 'getFileDiffUris' , ( ) => {
9190 it ( 'file exists locally' , async ( ) => {
92- sandbox . stub ( fs , 'existsSync ' ) . returns ( true )
91+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( true )
9392
9493 const { left, right } = await getFileDiffUris ( filePath , rightPath , tabId )
9594
@@ -101,10 +100,10 @@ describe('diff', () => {
101100 } )
102101
103102 it ( 'file does not exists locally' , async ( ) => {
104- sandbox . stub ( fs , 'existsSync ' ) . returns ( false )
103+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( false )
105104 const { left, right } = await getFileDiffUris ( filePath , rightPath , tabId )
106105
107- const leftExpected = getOriginalFileUri ( filePath , tabId )
106+ const leftExpected = await getOriginalFileUri ( filePath , tabId )
108107 assert . deepStrictEqual ( left , leftExpected )
109108
110109 const rightExpected = createAmazonQUri ( rightPath , tabId )
0 commit comments