@@ -73,6 +73,51 @@ describe('TemplateGenerativeModel', () => {
7373 { timeout : 5000 }
7474 ) ;
7575 } ) ;
76+
77+ it ( 'singleRequestOptions overrides requestOptions' , async ( ) => {
78+ const templateGenerateContentStub = stub (
79+ generateContentMethods ,
80+ 'templateGenerateContent'
81+ ) . resolves ( { } as any ) ;
82+ const model = new TemplateGenerativeModel ( fakeAI , { timeout : 1000 } ) ;
83+ const singleRequestOptions = { timeout : 2000 } ;
84+
85+ await model . generateContent (
86+ TEMPLATE_ID ,
87+ TEMPLATE_VARS ,
88+ singleRequestOptions
89+ ) ;
90+
91+ expect ( templateGenerateContentStub ) . to . have . been . calledOnceWith (
92+ model . _apiSettings ,
93+ TEMPLATE_ID ,
94+ { inputs : TEMPLATE_VARS } ,
95+ { timeout : 2000 }
96+ ) ;
97+ } ) ;
98+
99+ it ( 'singleRequestOptions is merged with requestOptions' , async ( ) => {
100+ const templateGenerateContentStub = stub (
101+ generateContentMethods ,
102+ 'templateGenerateContent'
103+ ) . resolves ( { } as any ) ;
104+ const abortController = new AbortController ( ) ;
105+ const model = new TemplateGenerativeModel ( fakeAI , { timeout : 1000 } ) ;
106+ const singleRequestOptions = { signal : abortController . signal } ;
107+
108+ await model . generateContent (
109+ TEMPLATE_ID ,
110+ TEMPLATE_VARS ,
111+ singleRequestOptions
112+ ) ;
113+
114+ expect ( templateGenerateContentStub ) . to . have . been . calledOnceWith (
115+ model . _apiSettings ,
116+ TEMPLATE_ID ,
117+ { inputs : TEMPLATE_VARS } ,
118+ { timeout : 1000 , signal : abortController . signal }
119+ ) ;
120+ } ) ;
76121 } ) ;
77122
78123 describe ( 'generateContentStream' , ( ) => {
@@ -92,5 +137,50 @@ describe('TemplateGenerativeModel', () => {
92137 { timeout : 5000 }
93138 ) ;
94139 } ) ;
140+
141+ it ( 'singleRequestOptions overrides requestOptions' , async ( ) => {
142+ const templateGenerateContentStreamStub = stub (
143+ generateContentMethods ,
144+ 'templateGenerateContentStream'
145+ ) . resolves ( { } as any ) ;
146+ const model = new TemplateGenerativeModel ( fakeAI , { timeout : 1000 } ) ;
147+ const singleRequestOptions = { timeout : 2000 } ;
148+
149+ await model . generateContentStream (
150+ TEMPLATE_ID ,
151+ TEMPLATE_VARS ,
152+ singleRequestOptions
153+ ) ;
154+
155+ expect ( templateGenerateContentStreamStub ) . to . have . been . calledOnceWith (
156+ model . _apiSettings ,
157+ TEMPLATE_ID ,
158+ { inputs : TEMPLATE_VARS } ,
159+ { timeout : 2000 }
160+ ) ;
161+ } ) ;
162+
163+ it ( 'singleRequestOptions is merged with requestOptions' , async ( ) => {
164+ const templateGenerateContentStreamStub = stub (
165+ generateContentMethods ,
166+ 'templateGenerateContentStream'
167+ ) . resolves ( { } as any ) ;
168+ const abortController = new AbortController ( ) ;
169+ const model = new TemplateGenerativeModel ( fakeAI , { timeout : 1000 } ) ;
170+ const singleRequestOptions = { signal : abortController . signal } ;
171+
172+ await model . generateContentStream (
173+ TEMPLATE_ID ,
174+ TEMPLATE_VARS ,
175+ singleRequestOptions
176+ ) ;
177+
178+ expect ( templateGenerateContentStreamStub ) . to . have . been . calledOnceWith (
179+ model . _apiSettings ,
180+ TEMPLATE_ID ,
181+ { inputs : TEMPLATE_VARS } ,
182+ { timeout : 1000 , signal : abortController . signal }
183+ ) ;
184+ } ) ;
95185 } ) ;
96186} ) ;
0 commit comments