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'
16+ import { FileSystem } from '../../../shared/fs/fs'
1717
1818describe ( 'diff' , ( ) => {
1919 const filePath = path . join ( '/' , 'foo' , 'fi' )
@@ -35,7 +35,7 @@ describe('diff', () => {
3535
3636 describe ( 'openDiff' , ( ) => {
3737 it ( 'file exists locally' , async ( ) => {
38- sandbox . stub ( fs , 'existsSync ' ) . returns ( true )
38+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( true )
3939 await openDiff ( filePath , rightPath , tabId )
4040
4141 const leftExpected = vscode . Uri . file ( filePath )
@@ -44,10 +44,10 @@ describe('diff', () => {
4444 } )
4545
4646 it ( 'file does not exists locally' , async ( ) => {
47- sandbox . stub ( fs , 'existsSync ' ) . returns ( false )
47+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( false )
4848 await openDiff ( filePath , rightPath , tabId )
4949
50- const leftExpected = getOriginalFileUri ( filePath , tabId )
50+ const leftExpected = await getOriginalFileUri ( filePath , tabId )
5151 const rightExpected = createAmazonQUri ( rightPath , tabId )
5252 assert . ok ( executeCommandSpy . calledWith ( 'vscode.diff' , leftExpected , rightExpected ) )
5353 } )
@@ -57,15 +57,15 @@ describe('diff', () => {
5757 const name = 'foo'
5858
5959 it ( 'file exists locally' , async ( ) => {
60- sandbox . stub ( fs , 'existsSync ' ) . returns ( true )
60+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( true )
6161 await openDeletedDiff ( filePath , name , tabId )
6262
6363 const expectedPath = vscode . Uri . file ( filePath )
6464 assert . ok ( executeCommandSpy . calledWith ( 'vscode.open' , expectedPath , { } , `${ name } (Deleted)` ) )
6565 } )
6666
6767 it ( 'file does not exists locally' , async ( ) => {
68- sandbox . stub ( fs , 'existsSync ' ) . returns ( false )
68+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( false )
6969 await openDeletedDiff ( filePath , name , tabId )
7070
7171 const expectedPath = createAmazonQUri ( 'empty' , tabId )
@@ -74,23 +74,23 @@ describe('diff', () => {
7474 } )
7575
7676 describe ( 'getOriginalFileUri' , ( ) => {
77- it ( 'file exists locally' , ( ) => {
78- sandbox . stub ( fs , 'existsSync ' ) . returns ( true )
79- assert . deepStrictEqual ( getOriginalFileUri ( filePath , tabId ) . fsPath , filePath )
77+ it ( 'file exists locally' , async ( ) => {
78+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( true )
79+ assert . deepStrictEqual ( ( await getOriginalFileUri ( filePath , tabId ) ) . fsPath , filePath )
8080 } )
8181
82- it ( 'file does not exists locally' , ( ) => {
83- sandbox . stub ( fs , 'existsSync ' ) . returns ( false )
82+ it ( 'file does not exists locally' , async ( ) => {
83+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( false )
8484 const expected = createAmazonQUri ( 'empty' , tabId )
85- assert . deepStrictEqual ( getOriginalFileUri ( filePath , tabId ) , expected )
85+ assert . deepStrictEqual ( await getOriginalFileUri ( filePath , tabId ) , expected )
8686 } )
8787 } )
8888
8989 describe ( 'getFileDiffUris' , ( ) => {
90- it ( 'file exists locally' , ( ) => {
91- sandbox . stub ( fs , 'existsSync ' ) . returns ( true )
90+ it ( 'file exists locally' , async ( ) => {
91+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( true )
9292
93- const { left, right } = getFileDiffUris ( filePath , rightPath , tabId )
93+ const { left, right } = await getFileDiffUris ( filePath , rightPath , tabId )
9494
9595 const leftExpected = vscode . Uri . file ( filePath )
9696 assert . deepStrictEqual ( left , leftExpected )
@@ -99,11 +99,11 @@ describe('diff', () => {
9999 assert . deepStrictEqual ( right , rightExpected )
100100 } )
101101
102- it ( 'file does not exists locally' , ( ) => {
103- sandbox . stub ( fs , 'existsSync ' ) . returns ( false )
104- const { left, right } = getFileDiffUris ( filePath , rightPath , tabId )
102+ it ( 'file does not exists locally' , async ( ) => {
103+ sandbox . stub ( FileSystem . prototype , 'exists ' ) . resolves ( false )
104+ const { left, right } = await getFileDiffUris ( filePath , rightPath , tabId )
105105
106- const leftExpected = getOriginalFileUri ( filePath , tabId )
106+ const leftExpected = await getOriginalFileUri ( filePath , tabId )
107107 assert . deepStrictEqual ( left , leftExpected )
108108
109109 const rightExpected = createAmazonQUri ( rightPath , tabId )
0 commit comments