@@ -2,6 +2,8 @@ import { describe, expect, it } from "vitest";
22import { ColumnType , ColumnTypeError } from "../src" ;
33import {
44 StringWritableStream ,
5+ _unescapeXml ,
6+ arrayBufferToString ,
57 base64ToUint8Array ,
68 convertToColumnType ,
79 dateToString ,
@@ -230,4 +232,47 @@ describe("Utils Tests", () => {
230232 expect ( ( ) => convertToColumnType ( "123" , "UNKNOWN" as ColumnType ) ) . toThrow ( ColumnTypeError ) ; // Unsupported
231233 } )
232234 } )
235+
236+ describe ( "arrayBufferToString" , ( ) => {
237+ it ( "should convert ArrayBuffer to string" , ( ) => {
238+ const encoder = new TextEncoder ( ) ;
239+ const buffer = encoder . encode ( "Hello World" ) . buffer ;
240+ const result = arrayBufferToString ( buffer ) ;
241+ expect ( result ) . toBe ( "Hello World" ) ;
242+ } ) ;
243+
244+ it ( "should handle empty ArrayBuffer" , ( ) => {
245+ const buffer = new ArrayBuffer ( 0 ) ;
246+ const result = arrayBufferToString ( buffer ) ;
247+ expect ( result ) . toBe ( "" ) ;
248+ } ) ;
249+ } )
250+ describe ( "_unescapeXml" , ( ) => {
251+ it ( "should unescape XML entities" , ( ) => {
252+ const input = `Test ` ;
253+ const expected = "Test \x0A" ;
254+ const result = _unescapeXml ( input ) ;
255+ expect ( result ) . toBe ( expected ) ;
256+ } ) ;
257+
258+ it ( "should handle empty string" , ( ) => {
259+ const input = "" ;
260+ const expected = "" ;
261+ const result = _unescapeXml ( input ) ;
262+ expect ( result ) . toBe ( expected ) ;
263+ } ) ;
264+
265+ it ( "should handle no entities" , ( ) => {
266+ const input = "Hello World" ;
267+ const expected = "Hello World" ;
268+ const result = _unescapeXml ( input ) ;
269+ expect ( result ) . toBe ( expected ) ;
270+ } ) ;
271+ it ( "should handle undefined input" , ( ) => {
272+ const input = undefined ;
273+ const expected = undefined ;
274+ const result = _unescapeXml ( input ) ;
275+ expect ( result ) . toBe ( expected ) ;
276+ } ) ;
277+ } )
233278} ) ;
0 commit comments