import 'mocha' ; import HttpStatus from '@xpring-eng/http-status' ; import * as request from 'supertest' ; import App from '../../../../src/app' ; import { appSetup , appCleanup } from '../../../helpers/helpers' ; let app ; const payIdApiVersion = '2020-05-28' ; const contentType = 'application/merge-patch+json' ; describe ( 'E2E - adminApiRouter - OPTIONS /users/:payId' , function ( ) : void { before ( async function ( ) { app = await appSetup ( ) ; } ) ; it ( 'Returns a 200 with PATCH in the Allow header' , function ( done ) : void { const payId = 'alice$xpring.money' ; request ( app . adminApiExpress ) . options ( `/users/${ payId }` ) . set ( 'PayID-API-Version' , payIdApiVersion ) . expect ( 'Allow' , /PATCH/u ) . expect ( HttpStatus . OK , done ) ; } ) ; it ( 'Returns a 200 with the appropriate Accept-Patch response header' , function ( done ) : void { const payId = 'alice$xpring.money' ; request ( app . adminApiExpress ) . options ( `/users/${ payId }` ) . set ( 'PayID-API-Version' , payIdApiVersion ) . expect ( 'Accept-Patch' , contentType ) . expect ( HttpStatus . OK , done ) ; } ) ; it ( 'Returns a 400 - the PayID-API-Version header is missing' , function ( done ) : void { const payId = 'alice$xpring.money' ; const expectedErrorResponse = { error : 'Bad Request' , message : "A PayID-API-Version header is required in the request, of the form 'PayID-API-Version: YYYY-MM-DD'." , statusCode : 400 , } ; request ( app . adminApiExpress ) . options ( `/users/${ payId }` ) . expect ( 'Content-Type' , /json/u ) . expect ( 'Accept-Patch' , contentType ) . expect ( HttpStatus . BadRequest , expectedErrorResponse , done ) ; } ) ; after ( function ( ) { appCleanup ( app ) ; } ) ; } ) ;