@@ -201,6 +201,53 @@ export default (testContext: {
201201 } )
202202 expect ( retrievedCredential . length ) . toBeGreaterThan ( 0 )
203203 } )
204+
205+ it ( 'should delete credentials without clearing the claims table' , async ( ) => {
206+ const credA = await agent . createVerifiableCredential ( {
207+ proofFormat : 'jwt' ,
208+ credential : {
209+ type : [ 'Important' ] ,
210+ credentialSubject : {
211+ important : 'yes' ,
212+ serious : true ,
213+ } ,
214+ issuer : identifier . did ,
215+ } ,
216+ } )
217+ const credB = await agent . createVerifiableCredential ( {
218+ proofFormat : 'jwt' ,
219+ credential : {
220+ type : [ 'Unimportant' ] ,
221+ credentialSubject : {
222+ bla : 'bla' ,
223+ } ,
224+ issuer : identifier . did ,
225+ } ,
226+ } )
227+
228+ const credAhash = await agent . dataStoreSaveVerifiableCredential ( { verifiableCredential : credA } )
229+ const credBhash = await agent . dataStoreSaveVerifiableCredential ( { verifiableCredential : credB } )
230+
231+ const queryBeforeDelete = await agent . dataStoreORMGetVerifiableCredentialsByClaims ( {
232+ where : [
233+ { column : 'type' , value : [ 'important' ] } ,
234+ { column : 'value' , value : [ 'yes' ] } ,
235+ ] ,
236+ } )
237+ expect ( queryBeforeDelete . length ) . toBeGreaterThan ( 0 )
238+ expect ( queryBeforeDelete [ 0 ] . hash ) . toEqual ( credAhash )
239+
240+ await agent . dataStoreDeleteVerifiableCredential ( { hash : credBhash } )
241+
242+ const queryAfterDelete = await agent . dataStoreORMGetVerifiableCredentialsByClaims ( {
243+ where : [
244+ { column : 'type' , value : [ 'important' ] } ,
245+ { column : 'value' , value : [ 'yes' ] } ,
246+ ] ,
247+ } )
248+ expect ( queryAfterDelete . length ) . toBeGreaterThan ( 0 )
249+ expect ( queryAfterDelete [ 0 ] . hash ) . toEqual ( credAhash )
250+ } )
204251 } )
205252 }
206253 } )
0 commit comments