1+ 'use strict' ;
2+
3+ require ( 'mocha' ) ;
4+ const assert = require ( 'assert' ) . strict ;
5+ const braces = require ( '..' ) ;
6+
7+ describe ( 'Examples from README.md' , ( ) => {
8+ describe ( 'Brace Expansion vs. Compilation' , ( ) => {
9+ it ( 'Compiled' , ( ) => {
10+ assert . deepEqual ( braces ( 'a/{x,y,z}/b' ) , [ 'a/(x|y|z)/b' ] ) ;
11+ assert . deepEqual ( braces ( [ 'a/{01..20}/b' , 'a/{1..5}/b' ] ) , [ 'a/(0[1-9]|1[0-9]|20)/b' , 'a/([1-5])/b' ] ) ;
12+ } ) ;
13+
14+ it ( 'Expanded' , ( ) => {
15+ assert . deepEqual ( braces ( 'a/{x,y,z}/b' , { expand : true } ) , [ 'a/x/b' , 'a/y/b' , 'a/z/b' ] ) ;
16+ assert . deepEqual ( braces . expand ( '{01..10}' ) , [ '01' , '02' , '03' , '04' , '05' , '06' , '07' , '08' , '09' , '10' ] ) ;
17+ } ) ;
18+ } ) ;
19+
20+ describe ( 'Sequences' , ( ) => {
21+ it ( 'first set of examples' , ( ) => {
22+ assert . deepEqual ( braces . expand ( '{1..3}' ) , [ '1' , '2' , '3' ] ) ;
23+ assert . deepEqual ( braces . expand ( 'a/{1..3}/b' ) , [ 'a/1/b' , 'a/2/b' , 'a/3/b' ] ) ;
24+ assert . deepEqual ( braces ( '{a..c}' , { expand : true } ) , [ 'a' , 'b' , 'c' ] ) ;
25+ assert . deepEqual ( braces ( 'foo/{a..c}' , { expand : true } ) , [ 'foo/a' , 'foo/b' , 'foo/c' ] ) ;
26+ } )
27+
28+ it ( 'zero-padding examples' , ( ) => {
29+ // supports zero-padded ranges
30+ assert . deepEqual ( braces ( 'a/{01..03}/b' ) , [ 'a/(0[1-3])/b' ] ) ;
31+ assert . deepEqual ( braces ( 'a/{001..300}/b' ) , [ 'a/(0{2}[1-9]|0[1-9][0-9]|[12][0-9]{2}|300)/b' ] ) ;
32+ } )
33+ } ) ;
34+ } ) ;
0 commit comments