@@ -537,32 +537,95 @@ describe("Unit Tests - Live Client Message Handling", () => {
537537 expect ( mockConnection . send ) . toHaveBeenCalledWith ( JSON . stringify ( { type : "KeepAlive" } ) ) ;
538538 } ) ;
539539
540- it ( "should send injectUserMessage correctly" , ( ) => {
541- const content = "Hello! Can you hear me?" ;
542- client . injectUserMessage ( content ) ;
540+ describe ( "speak provider configuration" , ( ) => {
541+ it ( "should accept single provider" , ( ) => {
542+ const config = {
543+ audio : { input : { encoding : "linear16" , sample_rate : 16000 } } ,
544+ agent : {
545+ speak : {
546+ provider : { type : "deepgram" , model : "aura-2-zeus-en" } ,
547+ } ,
548+ } ,
549+ } ;
543550
544- expect ( mockConnection . send ) . toHaveBeenCalledWith (
545- JSON . stringify ( { type : "InjectUserMessage" , content } )
546- ) ;
551+ client . configure ( config ) ;
552+ expect ( mockConnection . send ) . toHaveBeenCalledWith (
553+ JSON . stringify ( { type : "Settings" , ...config } )
554+ ) ;
555+ } ) ;
556+
557+ it ( "should accept array of providers" , ( ) => {
558+ const config = {
559+ audio : { input : { encoding : "linear16" , sample_rate : 16000 } } ,
560+ agent : {
561+ speak : [
562+ { provider : { type : "deepgram" , model : "aura-2-zeus-en" } } ,
563+ {
564+ provider : { type : "openai" , model : "tts-1" , voice : "shimmer" } ,
565+ endpoint : { url : "https://api.openai.com/v1/audio/speech" , headers : { auth : "key" } }
566+ } ,
567+ ] ,
568+ } ,
569+ } ;
570+
571+ client . configure ( config ) ;
572+ expect ( mockConnection . send ) . toHaveBeenCalledWith (
573+ JSON . stringify ( { type : "Settings" , ...config } )
574+ ) ;
575+ } ) ;
547576 } ) ;
548577
549- it ( "should send injectUserMessage with different content types" , ( ) => {
550- const testCases = [
551- "What's the weather like today?" ,
552- "Simple greeting" ,
553- "Multi-line\nmessage content" ,
554- "" , // Edge case: empty string
555- ] ;
578+ describe ( "updateSpeak method" , ( ) => {
579+ it ( "should update with single provider" , ( ) => {
580+ const provider = { provider : { type : "deepgram" , model : "aura-2-zeus-en" } } ;
581+
582+ client . updateSpeak ( provider ) ;
583+ expect ( mockConnection . send ) . toHaveBeenCalledWith (
584+ JSON . stringify ( { type : "UpdateSpeak" , speak : provider } )
585+ ) ;
586+ } ) ;
556587
557- testCases . forEach ( ( content ) => {
558- jest . clearAllMocks ( ) ; // Reset mock between test cases
588+ it ( "should update with array of providers" , ( ) => {
589+ const providers = [
590+ { provider : { type : "deepgram" , model : "aura-2-zeus-en" } } ,
591+ { provider : { type : "openai" , model : "tts-1" , voice : "shimmer" } } ,
592+ ] ;
559593
594+ client . updateSpeak ( providers ) ;
595+ expect ( mockConnection . send ) . toHaveBeenCalledWith (
596+ JSON . stringify ( { type : "UpdateSpeak" , speak : providers } )
597+ ) ;
598+ } ) ;
599+ } ) ;
600+
601+ describe ( "injectUserMessage method" , ( ) => {
602+ it ( "should send injectUserMessage correctly" , ( ) => {
603+ const content = "Hello! Can you hear me?" ;
560604 client . injectUserMessage ( content ) ;
561605
562606 expect ( mockConnection . send ) . toHaveBeenCalledWith (
563607 JSON . stringify ( { type : "InjectUserMessage" , content } )
564608 ) ;
565609 } ) ;
610+
611+ it ( "should send injectUserMessage with different content types" , ( ) => {
612+ const testCases = [
613+ "What's the weather like today?" ,
614+ "Simple greeting" ,
615+ "Multi-line\nmessage content" ,
616+ "" , // Edge case: empty string
617+ ] ;
618+
619+ testCases . forEach ( ( content ) => {
620+ jest . clearAllMocks ( ) ; // Reset mock between test cases
621+
622+ client . injectUserMessage ( content ) ;
623+
624+ expect ( mockConnection . send ) . toHaveBeenCalledWith (
625+ JSON . stringify ( { type : "InjectUserMessage" , content } )
626+ ) ;
627+ } ) ;
628+ } ) ;
566629 } ) ;
567630 } ) ;
568631} ) ;
0 commit comments