Skip to content

Commit e02be21

Browse files
committed
fix diff test
1 parent 9a63aa5 commit e02be21

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

packages/core/src/amazonq/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ export { amazonQHelpUrl } from '../shared/constants'
2727
export { listCodeWhispererCommandsWalkthrough } from '../codewhisperer/ui/statusBarMenu'
2828
export { focusAmazonQPanel, focusAmazonQPanelKeybinding } from '../codewhispererChat/commands/registerCommands'
2929
export { TryChatCodeLensProvider, tryChatCodeLensCommand } from '../codewhispererChat/editor/codelens'
30-
export { createAmazonQUri, openDiff, openDeletedDiff, getOriginalFileUri, getFileDiffUris } from './commons/diff'
30+
export {
31+
createAmazonQUri,
32+
openDiff,
33+
openDeletedDiff,
34+
getOriginalFileUri,
35+
getFileDiffUris,
36+
openFile,
37+
} from './commons/diff'
3138
export { CodeReference } from '../codewhispererChat/view/connector/connector'
3239
export { AuthMessageDataMap, AuthFollowUpType } from './auth/model'
3340
export { extractAuthFollowUp } from './util/authUtils'

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

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ import assert from 'assert'
1212
import * as path from 'path'
1313
import * as vscode from 'vscode'
1414
import 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'
1623
import { FileSystem } from '../../../shared/fs/fs'
1724

1825
describe('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

Comments
 (0)