@@ -27,30 +27,6 @@ describe("Multipart", function () {
2727 expect ( new TextDecoder ( ) . decode ( multipart . boundary ) ) . to . equal ( "empty-boundary" ) ;
2828 expect ( multipart . mediaType ) . to . equal ( "multipart/mixed" ) ;
2929 } ) ;
30-
31- it ( "should accept only valid boundaries" , function ( ) {
32- expect ( ( ) => new Multipart ( [ ] , "" ) ) . to . throw ( RangeError , "Invalid boundary" ) ;
33- expect ( ( ) => new Multipart ( [ ] , " " ) ) . to . throw ( RangeError , "Invalid boundary" ) ;
34- expect ( ( ) => new Multipart ( [ ] , "a " ) ) . to . throw ( RangeError , "Invalid boundary" ) ;
35- expect ( ( ) => new Multipart ( [ ] , "0123456789" . repeat ( 7 ) + "0" ) ) . to . throw ( RangeError , "Invalid boundary" ) ;
36- expect ( ( ) => new Multipart ( [ ] , "foo!bar" ) ) . to . throw ( RangeError , "Invalid boundary" ) ;
37-
38- expect ( ( ) => new Multipart ( [ ] , "a" ) ) . to . not . throw ( ) ;
39- expect ( ( ) => new Multipart ( [ ] , "0123456789" . repeat ( 7 ) ) ) . to . not . throw ( ) ;
40- expect ( ( ) => new Multipart ( [ ] , "foo bar" ) ) . to . not . throw ( ) ;
41- expect ( ( ) => new Multipart ( [ ] , "foo'bar" ) ) . to . not . throw ( ) ;
42- expect ( ( ) => new Multipart ( [ ] , "foo(bar" ) ) . to . not . throw ( ) ;
43- expect ( ( ) => new Multipart ( [ ] , "foo)bar" ) ) . to . not . throw ( ) ;
44- expect ( ( ) => new Multipart ( [ ] , "foo+bar" ) ) . to . not . throw ( ) ;
45- expect ( ( ) => new Multipart ( [ ] , "foo_bar" ) ) . to . not . throw ( ) ;
46- expect ( ( ) => new Multipart ( [ ] , "foo,bar" ) ) . to . not . throw ( ) ;
47- expect ( ( ) => new Multipart ( [ ] , "foo-bar" ) ) . to . not . throw ( ) ;
48- expect ( ( ) => new Multipart ( [ ] , "foo.bar" ) ) . to . not . throw ( ) ;
49- expect ( ( ) => new Multipart ( [ ] , "foo/bar" ) ) . to . not . throw ( ) ;
50- expect ( ( ) => new Multipart ( [ ] , "foo:bar" ) ) . to . not . throw ( ) ;
51- expect ( ( ) => new Multipart ( [ ] , "foo=bar" ) ) . to . not . throw ( ) ;
52- expect ( ( ) => new Multipart ( [ ] , "foo?bar" ) ) . to . not . throw ( ) ;
53- } ) ;
5430 } ) ;
5531
5632 describe ( "parse" , function ( ) {
@@ -276,5 +252,29 @@ describe("Multipart", function () {
276252
277253 expect ( new TextDecoder ( ) . decode ( bytes ) ) . to . equal ( new TextDecoder ( ) . decode ( expectedBytes ) ) ;
278254 } ) ;
255+
256+ it ( "should accept only valid boundaries" , function ( ) {
257+ expect ( ( ) => new Multipart ( [ ] , "" ) . bytes ( ) ) . to . throw ( RangeError , "Invalid boundary" ) ;
258+ expect ( ( ) => new Multipart ( [ ] , " " ) . bytes ( ) ) . to . throw ( RangeError , "Invalid boundary" ) ;
259+ expect ( ( ) => new Multipart ( [ ] , "a " ) . bytes ( ) ) . to . throw ( RangeError , "Invalid boundary" ) ;
260+ expect ( ( ) => new Multipart ( [ ] , "0123456789" . repeat ( 7 ) + "0" ) . bytes ( ) ) . to . throw ( RangeError , "Invalid boundary" ) ;
261+ expect ( ( ) => new Multipart ( [ ] , "foo!bar" ) . bytes ( ) ) . to . throw ( RangeError , "Invalid boundary" ) ;
262+
263+ expect ( ( ) => new Multipart ( [ ] , "a" ) . bytes ( ) ) . to . not . throw ( ) ;
264+ expect ( ( ) => new Multipart ( [ ] , "0123456789" . repeat ( 7 ) ) . bytes ( ) ) . to . not . throw ( ) ;
265+ expect ( ( ) => new Multipart ( [ ] , "foo bar" ) . bytes ( ) ) . to . not . throw ( ) ;
266+ expect ( ( ) => new Multipart ( [ ] , "foo'bar" ) . bytes ( ) ) . to . not . throw ( ) ;
267+ expect ( ( ) => new Multipart ( [ ] , "foo(bar" ) . bytes ( ) ) . to . not . throw ( ) ;
268+ expect ( ( ) => new Multipart ( [ ] , "foo)bar" ) . bytes ( ) ) . to . not . throw ( ) ;
269+ expect ( ( ) => new Multipart ( [ ] , "foo+bar" ) . bytes ( ) ) . to . not . throw ( ) ;
270+ expect ( ( ) => new Multipart ( [ ] , "foo_bar" ) . bytes ( ) ) . to . not . throw ( ) ;
271+ expect ( ( ) => new Multipart ( [ ] , "foo,bar" ) . bytes ( ) ) . to . not . throw ( ) ;
272+ expect ( ( ) => new Multipart ( [ ] , "foo-bar" ) . bytes ( ) ) . to . not . throw ( ) ;
273+ expect ( ( ) => new Multipart ( [ ] , "foo.bar" ) . bytes ( ) ) . to . not . throw ( ) ;
274+ expect ( ( ) => new Multipart ( [ ] , "foo/bar" ) . bytes ( ) ) . to . not . throw ( ) ;
275+ expect ( ( ) => new Multipart ( [ ] , "foo:bar" ) . bytes ( ) ) . to . not . throw ( ) ;
276+ expect ( ( ) => new Multipart ( [ ] , "foo=bar" ) . bytes ( ) ) . to . not . throw ( ) ;
277+ expect ( ( ) => new Multipart ( [ ] , "foo?bar" ) . bytes ( ) ) . to . not . throw ( ) ;
278+ } ) ;
279279 } ) ;
280280} ) ;
0 commit comments