import { getUrlPrefix } from './space_test_utils' ; interface ObjectToRemove { spaceId : string ; id : string ; type : string ; plugin : string ; } export class ObjectRemover { private readonly supertest : any ; private objectsToRemove : ObjectToRemove [ ] = [ ] ; constructor ( supertest ) { this . supertest = supertest ; } add ( spaceId , id , type , plugin ) { this . objectsToRemove . push ( { spaceId , id , type , plugin } ) ; } async removeAll ( ) { await Promise . all ( this . objectsToRemove . map ( ( { spaceId , id , type , plugin } ) => { return this . supertest . delete ( `${ getUrlPrefix ( spaceId ) }/api/${ plugin }/${ type }/${ id }` ) . set ( 'kbn-xsrf' , 'foo' ) . expect ( 204 ) ; } ) ) ; this . objectsToRemove = [ ] ; } }