import 'mocha' ; import * as chai from 'chai' ; import * as chaiAsPromised from 'chai-as-promised' ; import { getAllAddressInfoFromDatabase } from '../../../src/data-access/payIds' ; import { insertUser } from '../../../src/data-access/users' ; chai . use ( chaiAsPromised ) ; const { assert } = chai ; describe ( 'Data Access - PayID Regex - insertUser()' , function ( ) : void { const addresses = [ { paymentNetwork : 'XRPL' , environment : 'MAINNET' , details : { address : 'XV5sbjUmgPpvXv4ixFWZ5ptAYZ6PD28Sq49uo34VyjnmK5H' , } , } , ] ; it ( 'Accepts PayID with a lowercase letter for user' , async function ( ) { const payId = 'a$wallet.com' ; await insertUser ( payId , addresses ) ; const resp = await getAllAddressInfoFromDatabase ( payId ) ; assert . deepEqual ( resp , addresses ) ; } ) ; it ( 'Rejects PayID with a uppercase letter for user' , async function ( ) { const payId = 'A$wallet.com' ; const insertion = insertUser ( payId , addresses ) ; return assert . isRejected ( insertion ) ; } ) ; it ( 'Accepts PayID with a number for user' , async function ( ) { const payId = '1$wallet.com' ; await insertUser ( payId , addresses ) ; const resp = await getAllAddressInfoFromDatabase ( payId ) ; assert . deepEqual ( resp , addresses ) ; } ) ; it ( 'Accepts PayID with a user containing a period' , async function ( ) { const payId = 'first.last$wallet.com' ; await insertUser ( payId , addresses ) ; const resp = await getAllAddressInfoFromDatabase ( payId ) ; assert . deepEqual ( resp , addresses ) ; } ) ; it ( 'Accepts PayID with an _ for user' , async function ( ) { const payId = '_$wallet.com' ; await insertUser ( payId , addresses ) ; const resp = await getAllAddressInfoFromDatabase ( payId ) ; assert . deepEqual ( resp , addresses ) ; } ) ; it ( 'Accepts PayID with a hyphen for user' , async function ( ) { const payId = '-$wallet.com' ; await insertUser ( payId , addresses ) ; const resp = await getAllAddressInfoFromDatabase ( payId ) ; assert . deepEqual ( resp , addresses ) ; } ) ; it ( 'Accepts PayID with normal host' , async function ( ) { const payId = 'user$wallet.com' ; await insertUser ( payId , addresses ) ; const resp = await getAllAddressInfoFromDatabase ( payId ) ; assert . deepEqual ( resp , addresses ) ; } ) ; it ( 'Accepts PayID with a subdomain' , async function ( ) { const payId = 'user$subdomain.wallet.com' ; await insertUser ( payId , addresses ) ; const resp = await getAllAddressInfoFromDatabase ( payId ) ; assert . deepEqual ( resp , addresses ) ; } ) ; } ) ;