import { storage } from '@client/storage' ; import { pinLoader } from './utils' ; describe ( 'Unlock page loads Properly' , ( ) => { const expectedPin = '$2a$10$xQBLcbPgGQNu9p6zVchWuu6pmCrQIjcb6k2W1PIVUxVTE/PumWM82' ; beforeEach ( async ( ) => { const indexedDB = { USER_DETAILS : JSON . stringify ( { userMgntUserID : 'shakib75' } ) , USER_DATA : JSON . stringify ( [ { userID : 'shakib75' , userPIN : expectedPin , drafts : [ ] } ] ) } ; storage . getItem = jest . fn ( async ( key ) => Promise . resolve ( indexedDB [ key ] ) ) ; storage . setItem = jest . fn ( async ( key , value ) => ( indexedDB [ key ] = value ) ) ; } ) ; it ( 'Should retrieve user pin from index db' , async ( ) => { const receivedPin = await pinLoader . loadUserPin ( ) ; expect ( receivedPin ) . toEqual ( expectedPin ) ; } ) ; } ) ;