|
|
@@ -1,6 +1,7 @@
|
|
|
import { ClineProvider } from '../ClineProvider'
|
|
|
import * as vscode from 'vscode'
|
|
|
import { ExtensionMessage, ExtensionState } from '../../../shared/ExtensionMessage'
|
|
|
+import { setSoundEnabled } from '../../../utils/sound'
|
|
|
|
|
|
// Mock dependencies
|
|
|
jest.mock('vscode', () => ({
|
|
|
@@ -25,6 +26,11 @@ jest.mock('vscode', () => ({
|
|
|
}
|
|
|
}))
|
|
|
|
|
|
+// Mock sound utility
|
|
|
+jest.mock('../../../utils/sound', () => ({
|
|
|
+ setSoundEnabled: jest.fn()
|
|
|
+}))
|
|
|
+
|
|
|
// Mock ESM modules
|
|
|
jest.mock('p-wait-for', () => ({
|
|
|
__esModule: true,
|
|
|
@@ -233,4 +239,23 @@ describe('ClineProvider', () => {
|
|
|
expect(state).toHaveProperty('soundEnabled')
|
|
|
expect(state).toHaveProperty('diffEnabled')
|
|
|
})
|
|
|
+
|
|
|
+ test('updates sound utility when sound setting changes', async () => {
|
|
|
+ provider.resolveWebviewView(mockWebviewView)
|
|
|
+
|
|
|
+ // Get the message handler from onDidReceiveMessage
|
|
|
+ const messageHandler = (mockWebviewView.webview.onDidReceiveMessage as jest.Mock).mock.calls[0][0]
|
|
|
+
|
|
|
+ // Simulate setting sound to enabled
|
|
|
+ await messageHandler({ type: 'soundEnabled', bool: true })
|
|
|
+ expect(setSoundEnabled).toHaveBeenCalledWith(true)
|
|
|
+ expect(mockContext.globalState.update).toHaveBeenCalledWith('soundEnabled', true)
|
|
|
+ expect(mockPostMessage).toHaveBeenCalled()
|
|
|
+
|
|
|
+ // Simulate setting sound to disabled
|
|
|
+ await messageHandler({ type: 'soundEnabled', bool: false })
|
|
|
+ expect(setSoundEnabled).toHaveBeenCalledWith(false)
|
|
|
+ expect(mockContext.globalState.update).toHaveBeenCalledWith('soundEnabled', false)
|
|
|
+ expect(mockPostMessage).toHaveBeenCalled()
|
|
|
+ })
|
|
|
})
|