@@ -21,7 +21,6 @@ import {
2121 toStreamAudioContent ,
2222 ToContentText ,
2323} from '../../utils/rapida_content' ;
24- import { Content } from '../../clients/protos/common_pb' ;
2524
2625describe ( 'rapida_content' , ( ) => {
2726 describe ( 'ResponseContentType enum' , ( ) => {
@@ -111,101 +110,20 @@ describe('rapida_content', () => {
111110 } ) ;
112111
113112 describe ( 'toTextContent' , ( ) => {
114- it ( 'should create text content with default format' , ( ) => {
115- const content = toTextContent ( 'Hello, World!' ) ;
116-
117- expect ( content ) . toBeInstanceOf ( Content ) ;
118- expect ( content . getContenttype ( ) ) . toBe ( 'text' ) ;
119- expect ( content . getContentformat ( ) ) . toBe ( 'raw' ) ;
120- } ) ;
121-
122- it ( 'should create text content with specified format' , ( ) => {
123- const content = toTextContent ( 'Hello, World!' , 'word' ) ;
124-
125- expect ( content ) . toBeInstanceOf ( Content ) ;
126- expect ( content . getContenttype ( ) ) . toBe ( 'text' ) ;
127- expect ( content . getContentformat ( ) ) . toBe ( 'word' ) ;
128- } ) ;
129-
130- it ( 'should encode string content as Uint8Array' , ( ) => {
131- const text = 'Test message' ;
132- const content = toTextContent ( text ) ;
133-
134- const decoded = new TextDecoder ( ) . decode ( content . getContent ( ) as Uint8Array ) ;
135- expect ( decoded ) . toBe ( text ) ;
136- } ) ;
137-
138- it ( 'should handle empty string' , ( ) => {
139- const content = toTextContent ( '' ) ;
140-
141- expect ( content ) . toBeInstanceOf ( Content ) ;
142- const decoded = new TextDecoder ( ) . decode ( content . getContent ( ) as Uint8Array ) ;
143- expect ( decoded ) . toBe ( '' ) ;
144- } ) ;
145-
146- it ( 'should handle unicode characters' , ( ) => {
147- const text = 'こんにちは世界 🌍' ;
148- const content = toTextContent ( text ) ;
149-
150- const decoded = new TextDecoder ( ) . decode ( content . getContent ( ) as Uint8Array ) ;
151- expect ( decoded ) . toBe ( text ) ;
113+ it ( 'should throw not implemented error' , ( ) => {
114+ expect ( ( ) => toTextContent ( 'Hello, World!' ) ) . toThrow ( 'toTextContent not implemented' ) ;
152115 } ) ;
153116 } ) ;
154117
155118 describe ( 'toStreamAudioContent' , ( ) => {
156- it ( 'should create audio content with chunk format from Uint8Array' , ( ) => {
157- const audioData = new Uint8Array ( [ 1 , 2 , 3 , 4 , 5 ] ) ;
158- const content = toStreamAudioContent ( audioData ) ;
159-
160- expect ( content ) . toBeInstanceOf ( Content ) ;
161- expect ( content . getContenttype ( ) ) . toBe ( 'audio' ) ;
162- expect ( content . getContentformat ( ) ) . toBe ( 'chunk' ) ;
163- } ) ;
164-
165- it ( 'should create audio content from string' , ( ) => {
166- const audioData = 'audio-data-string' ;
167- const content = toStreamAudioContent ( audioData ) ;
168-
169- expect ( content ) . toBeInstanceOf ( Content ) ;
170- expect ( content . getContenttype ( ) ) . toBe ( 'audio' ) ;
171- expect ( content . getContentformat ( ) ) . toBe ( 'chunk' ) ;
119+ it ( 'should throw not implemented error' , ( ) => {
120+ expect ( ( ) => toStreamAudioContent ( new Uint8Array ( [ 1 , 2 , 3 ] ) ) ) . toThrow ( 'toStreamAudioContent not implemented' ) ;
172121 } ) ;
173122 } ) ;
174123
175124 describe ( 'ToContentText' , ( ) => {
176- it ( 'should return empty string for undefined content' , ( ) => {
177- expect ( ToContentText ( undefined ) ) . toBe ( '' ) ;
178- } ) ;
179-
180- it ( 'should return empty string for empty array' , ( ) => {
181- expect ( ToContentText ( [ ] ) ) . toBe ( '' ) ;
182- } ) ;
183-
184- it ( 'should extract text from text content array' , ( ) => {
185- const content1 = toTextContent ( 'Hello' ) ;
186- const content2 = toTextContent ( 'World' ) ;
187-
188- const result = ToContentText ( [ content1 , content2 ] ) ;
189-
190- expect ( result ) . toBe ( 'Hello World' ) ;
191- } ) ;
192-
193- it ( 'should filter out non-text content' , ( ) => {
194- const textContent = toTextContent ( 'Hello' ) ;
195- const audioContent = toStreamAudioContent ( new Uint8Array ( [ 1 , 2 , 3 ] ) ) ;
196-
197- const result = ToContentText ( [ textContent , audioContent ] ) ;
198-
199- expect ( result ) . toBe ( 'Hello' ) ;
200- } ) ;
201-
202- it ( 'should handle content with decoding errors gracefully' , ( ) => {
203- const content = new Content ( ) ;
204- content . setContenttype ( 'text' ) ;
205- content . setContent ( 'invalid' as any ) ; // Invalid content that might cause decode error
206-
207- // Should not throw, but return appropriate result
208- expect ( ( ) => ToContentText ( [ content ] ) ) . not . toThrow ( ) ;
125+ it ( 'should throw not implemented error' , ( ) => {
126+ expect ( ( ) => ToContentText ( [ ] ) ) . toThrow ( 'ToContentText not implemented' ) ;
209127 } ) ;
210128 } ) ;
211129} ) ;
0 commit comments