@@ -6,11 +6,6 @@ const { format, parse } = require('../lib/extension');
66
77describe ( 'extension' , ( ) => {
88 describe ( 'parse' , ( ) => {
9- it ( 'returns an empty object if the argument is `undefined`' , ( ) => {
10- assert . deepStrictEqual ( parse ( ) , { __proto__ : null } ) ;
11- assert . deepStrictEqual ( parse ( '' ) , { __proto__ : null } ) ;
12- } ) ;
13-
149 it ( 'parses a single extension' , ( ) => {
1510 assert . deepStrictEqual ( parse ( 'foo' ) , {
1611 foo : [ { __proto__ : null } ] ,
@@ -73,7 +68,7 @@ describe('extension', () => {
7368 } ) ;
7469
7570 it ( 'ignores the optional white spaces' , ( ) => {
76- const header = 'foo; bar\t; \tbaz=1\t ; bar="1"\t\t, \tqux\t ;norf ' ;
71+ const header = 'foo; bar\t; \tbaz=1\t ; bar="1"\t\t, \tqux\t ;norf' ;
7772
7873 assert . deepStrictEqual ( parse ( header ) , {
7974 foo : [ { bar : [ true , '1' ] , baz : [ '1' ] , __proto__ : null } ] ,
@@ -105,10 +100,12 @@ describe('extension', () => {
105100
106101 it ( 'throws an error if a white space is misplaced' , ( ) => {
107102 [
103+ [ ' foo' , 0 ] ,
108104 [ 'f oo' , 2 ] ,
109105 [ 'foo;ba r' , 7 ] ,
110106 [ 'foo;bar =' , 8 ] ,
111- [ 'foo;bar= ' , 8 ]
107+ [ 'foo;bar= ' , 8 ] ,
108+ [ 'foo;bar=ba z' , 11 ]
112109 ] . forEach ( ( element ) => {
113110 assert . throws (
114111 ( ) => parse ( element [ 0 ] ) ,
@@ -147,13 +144,18 @@ describe('extension', () => {
147144
148145 it ( 'throws an error if the header value ends prematurely' , ( ) => {
149146 [
147+ '' ,
148+ 'foo ' ,
149+ 'foo\t' ,
150150 'foo, ' ,
151151 'foo;' ,
152+ 'foo;bar ' ,
152153 'foo;bar,' ,
153154 'foo;bar; ' ,
154155 'foo;bar=' ,
155156 'foo;bar="baz' ,
156- 'foo;bar="1\\'
157+ 'foo;bar="1\\' ,
158+ 'foo;bar="baz" '
157159 ] . forEach ( ( header ) => {
158160 assert . throws (
159161 ( ) => parse ( header ) ,
0 commit comments