diff --git a/tests/test_publication.cairo b/tests/test_publication.cairo index 7850700..b09ff50 100644 --- a/tests/test_publication.cairo +++ b/tests/test_publication.cairo @@ -272,7 +272,7 @@ fn test_quote() { _, user_one_profile_address, user_two_profile_address, - _, + user_three_profile_address, user_one_first_post_pointed_pub_id, ) = __setup__(); @@ -301,6 +301,84 @@ fn test_quote() { stop_prank( CheatTarget::Multiple(array![publication_contract_address, profile_contract_address]), ); + + start_prank( + CheatTarget::Multiple(array![publication_contract_address, profile_contract_address]), + USER_TWO.try_into().unwrap() + ); + let user_two_quote_content_URI = "ipfs://QmSkDCsS32eLpcymxtn1cEn7Rc5hfefLBgfvZysdjbezo/"; + + let user_two_quote_params = QuoteParams { + profile_address: user_three_profile_address, + content_URI: user_two_quote_content_URI, + pointed_profile_address: user_one_profile_address, + pointed_pub_id: user_one_first_post_pointed_pub_id + }; + // user 2 publish quote to user 3 profile + let user_two_quote_pub_id = publication_dispatcher + .quote(user_two_quote_params, profile_contract_address); + + let publication_type = publication_dispatcher + .get_publication_type(user_three_profile_address, user_two_quote_pub_id); + assert(publication_type == PublicationType::Quote, 'invalid pub_type'); + + let user_one_publication_root_id = publication_dispatcher + .get_publication(user_two_profile_address, quote_pub_id) + .root_profile_address; + let user_two_publication_root_id = publication_dispatcher + .get_publication(user_three_profile_address, user_two_quote_pub_id) + .root_profile_address; + assert(user_one_publication_root_id == user_two_publication_root_id, 'Invalid root_id'); + + stop_prank( + CheatTarget::Multiple(array![publication_contract_address, profile_contract_address]), + ); +} + +#[test] +fn test_quote_pointed_profile_address() { + let ( + _, + _, + profile_contract_address, + publication_contract_address, + _, + _, + user_one_profile_address, + user_two_profile_address, + _, + user_one_first_post_pointed_pub_id, + ) = + __setup__(); + let publication_dispatcher = IKarstPublicationsDispatcher { + contract_address: publication_contract_address + }; + start_prank( + CheatTarget::Multiple(array![publication_contract_address, profile_contract_address]), + USER_ONE.try_into().unwrap() + ); + let quote_content_URI = "ipfs://QmSkDCsS32eLpcymxtn1cEn7Rc5hfefLBgfvZysddefzp/"; + + let quote_params = QuoteParams { + profile_address: user_two_profile_address, + content_URI: quote_content_URI, + pointed_profile_address: user_one_profile_address, + pointed_pub_id: user_one_first_post_pointed_pub_id + }; + + start_prank(CheatTarget::One(publication_contract_address), USER_ONE.try_into().unwrap()); + let profileDispatcher = IKarstProfileDispatcher { contract_address: profile_contract_address }; + + publication_dispatcher.quote(quote_params, profile_contract_address); + + let pointed_profile = profileDispatcher.get_profile(user_one_profile_address); + + assert( + pointed_profile.profile_address == user_one_profile_address, + 'Invalid Pointed Profile Address' + ); + + stop_prank(CheatTarget::One(publication_contract_address),); } #[test]