@@ -27,6 +27,19 @@ describe('HttpResponse.text()', () => {
27
27
} )
28
28
} )
29
29
30
+ it ( 'creates a text response with special characters' , async ( ) => {
31
+ const response = HttpResponse . text ( '안녕 세상' , { status : 201 } )
32
+
33
+ expect ( response . status ) . toBe ( 201 )
34
+ expect ( response . statusText ) . toBe ( 'Created' )
35
+ expect ( response . body ) . toBeInstanceOf ( ReadableStream )
36
+ expect ( await response . text ( ) ) . toBe ( '안녕 세상' )
37
+ expect ( Object . fromEntries ( response . headers . entries ( ) ) ) . toEqual ( {
38
+ 'content-length' : '13' ,
39
+ 'content-type' : 'text/plain' ,
40
+ } )
41
+ } )
42
+
30
43
it ( 'allows overriding the "Content-Type" response header' , async ( ) => {
31
44
const response = HttpResponse . text ( 'hello world' , {
32
45
headers : { 'Content-Type' : 'text/plain; charset=utf-8' } ,
@@ -68,6 +81,19 @@ describe('HttpResponse.json()', () => {
68
81
} )
69
82
} )
70
83
84
+ it ( 'creates a json response given an object with special characters' , async ( ) => {
85
+ const response = HttpResponse . json ( { firstName : '제로' } )
86
+
87
+ expect ( response . status ) . toBe ( 200 )
88
+ expect ( response . statusText ) . toBe ( 'OK' )
89
+ expect ( response . body ) . toBeInstanceOf ( ReadableStream )
90
+ expect ( await response . json ( ) ) . toEqual ( { firstName : '제로' } )
91
+ expect ( Object . fromEntries ( response . headers . entries ( ) ) ) . toEqual ( {
92
+ 'content-length' : '22' ,
93
+ 'content-type' : 'application/json' ,
94
+ } )
95
+ } )
96
+
71
97
it ( 'creates a json response given an array' , async ( ) => {
72
98
const response = HttpResponse . json ( [ 1 , 2 , 3 ] )
73
99
0 commit comments