File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010import { secureRandomInt } from "./cryptoRandom.js" ;
1111
1212export function generatePassword ( {
13- length = 16 ,
13+ length = 20 ,
1414 lowerCase = true ,
1515 upperCase = true ,
1616 digits= true ,
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ describe('generatePassword', () => {
1313 } ) ;
1414
1515 test ( 'should generate password with default length 16' , ( ) => {
16- const password = generatePassword ( { } ) ;
16+ const password = generatePassword ( { length : 16 } ) ;
1717 expect ( password ) . toHaveLength ( 16 ) ;
1818 } ) ;
1919
@@ -213,11 +213,11 @@ describe('generatePassword', () => {
213213 describe ( 'Default parameters' , ( ) => {
214214 test ( 'should use default values when no parameters provided' , ( ) => {
215215 const password = generatePassword ( { } ) ;
216- expect ( password ) . toHaveLength ( 16 ) ;
216+ expect ( password ) . toHaveLength ( 20 ) ;
217217 expect ( / [ a - z ] / . test ( password ) ) . toBe ( true ) ;
218218 expect ( / [ A - Z ] / . test ( password ) ) . toBe ( true ) ;
219219 expect ( / [ 0 - 9 ] / . test ( password ) ) . toBe ( true ) ;
220- expect ( / [ ! @ # $ % ^ & * ( ) \- = _ + \[ \] { } | ; : , . < > ? / ~ ` ] / . test ( password ) ) . toBe ( false ) ; // symbols false by default
220+ expect ( / [ ! @ # $ % ^ & * ( ) \- = _ + \[ \] { } | ; : , . < > ? / ~ ` ] / . test ( password ) ) . toBe ( true ) ; // symbols false by default
221221 } ) ;
222222
223223 test ( 'should use provided parameters over defaults' , ( ) => {
You can’t perform that action at this time.
0 commit comments