@@ -8,7 +8,7 @@ import { processStreamWithTags } from '../xml-stream-parser'
88describe ( 'processStreamWithTags' , ( ) => {
99 async function * createMockStream ( chunks : string [ ] ) {
1010 for ( const chunk of chunks ) {
11- yield chunk
11+ yield { type : 'text' as const , text : chunk }
1212 }
1313 }
1414
@@ -43,7 +43,9 @@ describe('processStreamWithTags', () => {
4343 onError ,
4444 ( ) => { } ,
4545 ) ) {
46- result . push ( chunk )
46+ if ( chunk . type === 'text' ) {
47+ result . push ( chunk . text )
48+ }
4749 }
4850
4951 expect ( events ) . toEqual ( [
@@ -94,7 +96,9 @@ describe('processStreamWithTags', () => {
9496 onError ,
9597 ( ) => { } ,
9698 ) ) {
97- result . push ( chunk )
99+ if ( chunk . type === 'text' ) {
100+ result . push ( chunk . text )
101+ }
98102 }
99103
100104 expect ( events ) . toEqual ( [
@@ -154,7 +158,9 @@ describe('processStreamWithTags', () => {
154158 onError ,
155159 ( ) => { } ,
156160 ) ) {
157- result . push ( chunk )
161+ if ( chunk . type === 'text' ) {
162+ result . push ( chunk . text )
163+ }
158164 }
159165
160166 expect ( events ) . toEqual ( [
@@ -213,7 +219,9 @@ describe('processStreamWithTags', () => {
213219 onError ,
214220 ( ) => { } ,
215221 ) ) {
216- result . push ( chunk )
222+ if ( chunk . type === 'text' ) {
223+ result . push ( chunk . text )
224+ }
217225 }
218226
219227 expect ( events ) . toEqual ( [
@@ -257,7 +265,9 @@ describe('processStreamWithTags', () => {
257265 onError ,
258266 ( ) => { } ,
259267 ) ) {
260- result . push ( chunk )
268+ if ( chunk . type === 'text' ) {
269+ result . push ( chunk . text )
270+ }
261271 }
262272
263273 expect ( events ) . toEqual ( [
@@ -306,7 +316,9 @@ describe('processStreamWithTags', () => {
306316 onError ,
307317 ( ) => { } ,
308318 ) ) {
309- result . push ( chunk )
319+ if ( chunk . type === 'text' ) {
320+ result . push ( chunk . text )
321+ }
310322 }
311323
312324 expect ( events ) . toEqual ( [
@@ -362,7 +374,9 @@ describe('processStreamWithTags', () => {
362374 onError ,
363375 ( ) => { } ,
364376 ) ) {
365- result . push ( chunk )
377+ if ( chunk . type === 'text' ) {
378+ result . push ( chunk . text )
379+ }
366380 }
367381
368382 expect ( events ) . toEqual ( [
@@ -412,7 +426,9 @@ describe('processStreamWithTags', () => {
412426 onError ,
413427 ( ) => { } ,
414428 ) ) {
415- result . push ( chunk )
429+ if ( chunk . type === 'text' ) {
430+ result . push ( chunk . text )
431+ }
416432 }
417433
418434 // Should complete the tool call with the completion suffix
@@ -452,7 +468,9 @@ describe('processStreamWithTags', () => {
452468 onError ,
453469 ( ) => { } ,
454470 ) ) {
455- result . push ( chunk )
471+ if ( chunk . type === 'text' ) {
472+ result . push ( chunk . text )
473+ }
456474 }
457475
458476 expect ( events ) . toEqual ( [ ] )
@@ -478,7 +496,9 @@ describe('processStreamWithTags', () => {
478496 onError ,
479497 ( ) => { } ,
480498 ) ) {
481- result . push ( chunk )
499+ if ( chunk . type === 'text' ) {
500+ result . push ( chunk . text )
501+ }
482502 }
483503
484504 expect ( events ) . toEqual ( [ ] )
@@ -516,7 +536,9 @@ describe('processStreamWithTags', () => {
516536 onError ,
517537 ( ) => { } ,
518538 ) ) {
519- result . push ( chunk )
539+ if ( chunk . type === 'text' ) {
540+ result . push ( chunk . text )
541+ }
520542 }
521543
522544 expect ( events ) . toEqual ( [
@@ -569,7 +591,9 @@ describe('processStreamWithTags', () => {
569591 onError ,
570592 ( ) => { } ,
571593 ) ) {
572- result . push ( chunk )
594+ if ( chunk . type === 'text' ) {
595+ result . push ( chunk . text )
596+ }
573597 }
574598
575599 expect ( events ) . toEqual ( [
0 commit comments