|
|
@@ -61,13 +61,16 @@ vi.mock('lucide-react', () => ({
|
|
|
WifiOff: () => <span>WifiOff</span>
|
|
|
}));
|
|
|
|
|
|
-const mockUseAgoraSTT = vi.mocked(require('@/client/hooks/useAgoraSTT').useAgoraSTT);
|
|
|
+import { useAgoraSTT } from '@/client/hooks/useAgoraSTT';
|
|
|
+
|
|
|
+const mockUseAgoraSTT = vi.mocked(useAgoraSTT);
|
|
|
|
|
|
describe('AgoraSTTComponent', () => {
|
|
|
const defaultState = {
|
|
|
isConnected: false,
|
|
|
isRecording: false,
|
|
|
isTranscribing: false,
|
|
|
+ isConnecting: false,
|
|
|
error: null,
|
|
|
transcriptionResults: [],
|
|
|
currentTranscription: ''
|
|
|
@@ -102,7 +105,7 @@ describe('AgoraSTTComponent', () => {
|
|
|
|
|
|
it('shows connection status when connected', () => {
|
|
|
mockUseAgoraSTT.mockReturnValue({
|
|
|
- state: { ...defaultState, isConnected: true },
|
|
|
+ state: { ...defaultState, isConnected: true, isConnecting: false },
|
|
|
joinChannel: mockJoinChannel,
|
|
|
leaveChannel: mockLeaveChannel,
|
|
|
startRecording: mockStartRecording,
|
|
|
@@ -118,7 +121,7 @@ describe('AgoraSTTComponent', () => {
|
|
|
|
|
|
it('shows recording status when recording', () => {
|
|
|
mockUseAgoraSTT.mockReturnValue({
|
|
|
- state: { ...defaultState, isConnected: true, isRecording: true },
|
|
|
+ state: { ...defaultState, isConnected: true, isRecording: true, isConnecting: false },
|
|
|
joinChannel: mockJoinChannel,
|
|
|
leaveChannel: mockLeaveChannel,
|
|
|
startRecording: mockStartRecording,
|
|
|
@@ -134,7 +137,7 @@ describe('AgoraSTTComponent', () => {
|
|
|
|
|
|
it('shows error message when there is an error', () => {
|
|
|
mockUseAgoraSTT.mockReturnValue({
|
|
|
- state: { ...defaultState, error: 'Configuration error' },
|
|
|
+ state: { ...defaultState, error: 'Configuration error', isConnecting: false },
|
|
|
joinChannel: mockJoinChannel,
|
|
|
leaveChannel: mockLeaveChannel,
|
|
|
startRecording: mockStartRecording,
|
|
|
@@ -160,7 +163,7 @@ describe('AgoraSTTComponent', () => {
|
|
|
|
|
|
it('calls startRecording when start button is clicked', async () => {
|
|
|
mockUseAgoraSTT.mockReturnValue({
|
|
|
- state: { ...defaultState, isConnected: true },
|
|
|
+ state: { ...defaultState, isConnected: true, isConnecting: false },
|
|
|
joinChannel: mockJoinChannel,
|
|
|
leaveChannel: mockLeaveChannel,
|
|
|
startRecording: mockStartRecording,
|
|
|
@@ -189,7 +192,7 @@ describe('AgoraSTTComponent', () => {
|
|
|
];
|
|
|
|
|
|
mockUseAgoraSTT.mockReturnValue({
|
|
|
- state: { ...defaultState, isConnected: true, transcriptionResults },
|
|
|
+ state: { ...defaultState, isConnected: true, transcriptionResults, isConnecting: false },
|
|
|
joinChannel: mockJoinChannel,
|
|
|
leaveChannel: mockLeaveChannel,
|
|
|
startRecording: mockStartRecording,
|
|
|
@@ -214,7 +217,7 @@ describe('AgoraSTTComponent', () => {
|
|
|
];
|
|
|
|
|
|
mockUseAgoraSTT.mockReturnValue({
|
|
|
- state: { ...defaultState, isConnected: true, transcriptionResults },
|
|
|
+ state: { ...defaultState, isConnected: true, transcriptionResults, isConnecting: false },
|
|
|
joinChannel: mockJoinChannel,
|
|
|
leaveChannel: mockLeaveChannel,
|
|
|
startRecording: mockStartRecording,
|