File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ for (let type of ['node', 'browser']) {
2929 } )
3030 }
3131
32+ test ( 'is ready for 0 size' , ( ) => {
33+ equal ( nanoid ( 0 ) , '' )
34+ } )
35+
3236 test ( `generates URL-friendly IDs` , ( ) => {
3337 for ( let i = 0 ; i < 100 ; i ++ ) {
3438 let id = nanoid ( )
@@ -179,11 +183,6 @@ for (let type of ['node', 'browser']) {
179183 }
180184 } )
181185
182- test ( `${ type } / customAlphabet / does not fall in infinite loop` , ( ) => {
183- equal ( nanoid ( 0 ) , '' )
184- equal ( customAlphabet ( 'abc' , 0 ) ( 0 ) , '' )
185- } )
186-
187186 if ( type === 'node' ) {
188187 test ( `${ type } / proxy number / prevent collision` , ( ) => {
189188 let makeProxyNumberToReproducePreviousID = ( ) => {
@@ -215,6 +214,11 @@ for (let type of ['node', 'browser']) {
215214 let id2 = nanoid ( makeProxyNumberToReproducePreviousID ( ) )
216215 notEqual ( id1 , id2 )
217216 } )
217+
218+ test ( `${ type } / customAlphabet / does not fall in infinite loop` , ( ) => {
219+ equal ( customAlphabet ( 'abc' ) ( 0 ) , '' )
220+ equal ( customAlphabet ( 'abc' , 0 ) ( 0 ) , '' )
221+ } )
218222 }
219223 } )
220224}
You can’t perform that action at this time.
0 commit comments