@@ -327,8 +327,8 @@ describe("AttributesController", function () {
327327 } ) ;
328328 } ) ;
329329
330- describe ( "change ForwardingDetails of Attributes" , function ( ) {
331- test ( "should allow to add ForwardingDetails to an OwnIdentityAttribute" , async function ( ) {
330+ describe ( "change AttributeForwardingDetails of Attributes" , function ( ) {
331+ test ( "should allow to add AttributeForwardingDetails to an OwnIdentityAttribute" , async function ( ) {
332332 const attributeParams = {
333333 content : IdentityAttribute . from ( {
334334 value : {
@@ -350,7 +350,7 @@ describe("AttributesController", function () {
350350 expect ( isForwarded ) . toBe ( true ) ;
351351 } ) ;
352352
353- test ( "should allow to add ForwardingDetails to an OwnRelationshipAttribute" , async function ( ) {
353+ test ( "should allow to add AttributeForwardingDetails to an OwnRelationshipAttribute" , async function ( ) {
354354 const thirdPartyAddress = CoreAddress . from ( "thirdPartyAdress" ) ;
355355 const peerAddress = CoreAddress . from ( "peerAddress" ) ;
356356
@@ -381,7 +381,7 @@ describe("AttributesController", function () {
381381 expect ( isForwarded ) . toBe ( true ) ;
382382 } ) ;
383383
384- test ( "should allow to add ForwardingDetails to a PeerRelationshipAttribute" , async function ( ) {
384+ test ( "should allow to add AttributeForwardingDetails to a PeerRelationshipAttribute" , async function ( ) {
385385 const thirdPartyAddress = CoreAddress . from ( "thirdPartyAdress" ) ;
386386 const peerAddress = CoreAddress . from ( "peerAddress" ) ;
387387
@@ -412,7 +412,7 @@ describe("AttributesController", function () {
412412 expect ( isForwarded ) . toBe ( true ) ;
413413 } ) ;
414414
415- test ( "should publish an event adding ForwardingDetails to an Attribute" , async function ( ) {
415+ test ( "should publish an event adding AttributeForwardingDetails to an Attribute" , async function ( ) {
416416 const attributeParams = {
417417 content : IdentityAttribute . from ( {
418418 value : {
@@ -431,7 +431,7 @@ describe("AttributesController", function () {
431431 mockEventBus . expectLastPublishedEvent ( AttributeForwardingDetailsChangedEvent , forwardedAttribute ) ;
432432 } ) ;
433433
434- test ( "should throw trying to add ForwardingDetails to an Attribute if it is already forwarded" , async function ( ) {
434+ test ( "should throw trying to add AttributeForwardingDetails to an Attribute if it is already forwarded" , async function ( ) {
435435 const attributeParams = {
436436 content : IdentityAttribute . from ( {
437437 value : {
@@ -449,7 +449,7 @@ describe("AttributesController", function () {
449449 ) ;
450450 } ) ;
451451
452- test ( "should allow to add ForwardingDetails to an Attribute if it is already forwarded but DeletedByRecipient" , async function ( ) {
452+ test ( "should allow to add AttributeForwardingDetails to an Attribute if it is already forwarded but DeletedByRecipient" , async function ( ) {
453453 const attributeParams = {
454454 content : IdentityAttribute . from ( {
455455 value : {
@@ -472,7 +472,7 @@ describe("AttributesController", function () {
472472 expect ( updatedAttribute . numberOfForwards ) . toBe ( 2 ) ;
473473 } ) ;
474474
475- test ( "should updated ForwardingDetails of an Attribute if it is already forwarded but ToBeDeletedByRecipient" , async function ( ) {
475+ test ( "should updated AttributeForwardingDetails of an Attribute if it is already forwarded but ToBeDeletedByRecipient" , async function ( ) {
476476 const attributeParams = {
477477 content : IdentityAttribute . from ( {
478478 value : {
@@ -498,7 +498,7 @@ describe("AttributesController", function () {
498498 expect ( forwardingDetails [ 0 ] . deletionInfo ) . toBeUndefined ( ) ;
499499 } ) ;
500500
501- test ( "should remove ForwardingDetails from an Attribute" , async function ( ) {
501+ test ( "should delete AttributeForwardingDetails for an Attribute" , async function ( ) {
502502 const attributeParams = {
503503 content : IdentityAttribute . from ( {
504504 value : {
@@ -516,12 +516,13 @@ describe("AttributesController", function () {
516516 const isForwarded = await consumptionController . attributes . isAttributeForwardedToPeer ( forwardedAttribute , peer ) ;
517517 expect ( isForwarded ) . toBe ( true ) ;
518518
519- const updatedAttribute = await consumptionController . attributes . removeForwardingDetailsFromAttribute ( forwardedAttribute , peer ) ;
520- const updatedIsForwarded = await consumptionController . attributes . isAttributeForwardedToPeer ( updatedAttribute , peer ) ;
519+ await consumptionController . attributes . deleteForwardingDetailsForAttribute ( forwardedAttribute , peer ) ;
520+ const updatedAttribute = await consumptionController . attributes . getLocalAttribute ( forwardedAttribute . id ) ;
521+ const updatedIsForwarded = await consumptionController . attributes . isAttributeForwardedToPeer ( updatedAttribute ! , peer ) ;
521522 expect ( updatedIsForwarded ) . toBe ( false ) ;
522523 } ) ;
523524
524- test ( "should publish an event when removing ForwardingDetails from an Attribute" , async function ( ) {
525+ test ( "should publish an event when removing AttributeForwardingDetails from an Attribute" , async function ( ) {
525526 const attributeParams = {
526527 content : IdentityAttribute . from ( {
527528 value : {
@@ -537,11 +538,12 @@ describe("AttributesController", function () {
537538 const forwardedAttribute = await consumptionController . attributes . addForwardingDetailsToAttribute ( attribute , peer , CoreId . from ( "aSourceReferenceId" ) ) ;
538539 mockEventBus . clearPublishedEvents ( ) ;
539540
540- const updatedAttribute = await consumptionController . attributes . removeForwardingDetailsFromAttribute ( forwardedAttribute , peer ) ;
541+ await consumptionController . attributes . deleteForwardingDetailsForAttribute ( forwardedAttribute , peer ) ;
542+ const updatedAttribute = ( await consumptionController . attributes . getLocalAttribute ( forwardedAttribute . id ) ) as OwnIdentityAttribute ;
541543 mockEventBus . expectLastPublishedEvent ( AttributeForwardingDetailsChangedEvent , updatedAttribute ) ;
542544 } ) ;
543545
544- test ( "should not change Attribute trying to remove ForwardingDetails from an Attribute without ForwardingDetails " , async function ( ) {
546+ test ( "should not change Attribute trying to remove AttributeForwardingDetails from an Attribute without AttributeForwardingDetails " , async function ( ) {
545547 const attributeParams = {
546548 content : IdentityAttribute . from ( {
547549 value : {
@@ -554,7 +556,9 @@ describe("AttributesController", function () {
554556 const attributeWithoutForwardingDetails = await consumptionController . attributes . createOwnIdentityAttribute ( attributeParams ) ;
555557
556558 const peer = CoreAddress . from ( "address" ) ;
557- const unchangedAttribute = await consumptionController . attributes . removeForwardingDetailsFromAttribute ( attributeWithoutForwardingDetails , peer ) ;
559+ await consumptionController . attributes . deleteForwardingDetailsForAttribute ( attributeWithoutForwardingDetails , peer ) ;
560+
561+ const unchangedAttribute = await consumptionController . attributes . getLocalAttribute ( attributeWithoutForwardingDetails . id ) ;
558562 expect ( unchangedAttribute ) . toStrictEqual ( attributeWithoutForwardingDetails ) ;
559563 } ) ;
560564 } ) ;
@@ -1044,6 +1048,26 @@ describe("AttributesController", function () {
10441048 expect ( peerAttribute ) . toBeUndefined ( ) ;
10451049 } ) ;
10461050
1051+ test ( "should delete AttributeForwardingDetails when deleting an Attribute" , async function ( ) {
1052+ const attribute = await consumptionController . attributes . createOwnIdentityAttribute ( {
1053+ content : IdentityAttribute . from ( {
1054+ value : EMailAddress . from ( {
1055+ value : "my@email.address"
1056+ } ) ,
1057+ owner : consumptionController . accountController . identity . address
1058+ } )
1059+ } ) ;
1060+ await consumptionController . attributes . addForwardingDetailsToAttribute ( attribute , CoreAddress . from ( "aPeer" ) , CoreId . from ( "aSourceReference" ) ) ;
1061+
1062+ const forwardingDetailsBeforeAttributeDeletion = await consumptionController . attributes . getForwardingDetailsForAttribute ( attribute ) ;
1063+ expect ( forwardingDetailsBeforeAttributeDeletion ) . toHaveLength ( 1 ) ;
1064+
1065+ await consumptionController . attributes . deleteAttribute ( attribute . id ) ;
1066+
1067+ const forwardingDetailsAfterAttributeDeletion = await consumptionController . attributes . getForwardingDetailsForAttribute ( attribute ) ;
1068+ expect ( forwardingDetailsAfterAttributeDeletion ) . toHaveLength ( 0 ) ;
1069+ } ) ;
1070+
10471071 describe ( "should validate and execute full Attribute deletion process" , function ( ) {
10481072 let predecessorOwnIdentityAttribute : OwnIdentityAttribute ;
10491073 let successorOwnIdentityAttribute : OwnIdentityAttribute ;
0 commit comments