@@ -67,6 +67,40 @@ describe('node-static (CLI)', function () {
6767 assert . equal ( text , 'hello world' , 'should respond with hello world' ) ;
6868 } ) ;
6969
70+ it ( 'serving file within directory with UTF-8 content-type' , async function ( ) {
71+ const { response /* , stdout */ } =
72+ /**
73+ * @type {{
74+ * response: Response,
75+ * stdout: string
76+ * }}
77+ */ ( await spawnConditional (
78+ binFile ,
79+ [
80+ '-p' , this . port , fixturePath ,
81+ '-H' , JSON . stringify ( {
82+ 'Content-Type' : 'text/html;charset=UTF-8'
83+ } )
84+ ] ,
85+ timeout - 9000 ,
86+ {
87+ condition : / s e r v i n g " .* ?" / ,
88+ action : ( /* err, stdout */ ) => {
89+ return fetch (
90+ `http://localhost:${ this . port } /utf8.html`
91+ ) ;
92+ }
93+ } ) ) ;
94+
95+ const { status} = response ;
96+ const contentType = response . headers . get ( 'content-type' ) ;
97+ const text = await response . text ( ) ;
98+
99+ assert . equal ( status , 200 , 'should respond with 200' ) ;
100+ assert . equal ( contentType , 'text/html' , 'should respond with text/html' ) ;
101+ assert . include ( text , '你好,世界!' , 'should respond with hello world in Chinese' ) ;
102+ } ) ;
103+
70104 it ( 'serving file within directory with server info' , async function ( ) {
71105 const { response /* , stdout */ } =
72106 /**
0 commit comments