import { pinValidator } from '@client/views/Unlock/ComparePINs' ; import * as bcrypt from 'bcryptjs' ; import { pinLoader } from '@client/views/Unlock/utils' ; describe ( 'Compare two PINs' , ( ) => { const pin = '1212' ; beforeEach ( ( ) => { const salt = bcrypt . genSaltSync ( 10 ) ; const hash = bcrypt . hashSync ( pin , salt ) ; pinLoader . loadUserPin = jest . fn ( async ( ) => Promise . resolve ( hash ) ) ; } ) ; it ( 'should return true when PINs match' , async ( ) => { const result = await pinValidator . isValidPin ( pin ) ; expect ( result ) . toBe ( true ) ; } ) ; it ( 'should return false when PINs do not match' , async ( ) => { const invalidPin = '2121' ; const result = await pinValidator . isValidPin ( invalidPin ) ; expect ( result ) . toBe ( false ) ; } ) ; } ) ;