Skip to content

Commit e9e7760

Browse files
committed
fix half-baked implementation
1 parent aab051e commit e9e7760

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

packages/core/src/test/amazonq/common/diff.test.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import assert from 'assert'
1212
import * as path from 'path'
1313
import * as vscode from 'vscode'
14-
import fs from 'fs'
1514
import sinon from 'sinon'
1615
import { createAmazonQUri, getFileDiffUris, getOriginalFileUri, openDeletedDiff, openDiff } from '../../../amazonq'
1716
import { 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

Comments
 (0)