import HttpStatus from '@xpring-eng/http-status' ; import * as request from 'supertest' ; import App from '../../../../src/app' ; import { appCleanup , appSetup } from '../../../helpers/helpers' ; import * as discoveryLinks from './testDiscoveryLinks.json' ; let app ; const discoveryPath = '/.well-known/webfinger' ; describe ( 'E2E - publicAPIRouter - PayID Discovery' , function ( ) : void { before ( async function ( ) { app = await appSetup ( ) ; } ) ; it ( 'Discovery query returns JRD' , function ( done ) : void { const payId = 'alice$wallet.com' ; const expectedResponse = { subject : payId , links : discoveryLinks , } ; request ( app . publicApiExpress ) . get ( `${ discoveryPath }?resource=${ payId }` ) . expect ( HttpStatus . OK , expectedResponse , done ) ; } ) ; it ( 'Discovery query with no PayID in request parameter returns 400' , function ( done ) : void { const expectedErrorResponse = { statusCode : 400 , error : 'Bad Request' , message : 'A PayID must be provided in the `resource` request parameter.' , } ; request ( app . publicApiExpress ) . get ( discoveryPath ) . expect ( HttpStatus . BadRequest , expectedErrorResponse , done ) ; } ) ; after ( function ( ) { appCleanup ( app ) ; } ) ; } ) ;