diff options
author | Derf Null <derf@finalrewind.org> | 2023-06-01 22:07:01 +0200 |
---|---|---|
committer | Derf Null <derf@finalrewind.org> | 2023-06-01 22:07:01 +0200 |
commit | b2feb1b664c575ce04a4a00c1a860ef07dae732d (patch) | |
tree | e2162c562b20bc65d4dbbdf90bb5013f2724dc9c /t | |
parent | 9332f60a4370cc5ec9a000ef505e613f84b17d2f (diff) |
Users: Add unfollow action
Diffstat (limited to 't')
-rw-r--r-- | t/21-relations.t | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/t/21-relations.t b/t/21-relations.t index d34e3ea..5af691a 100644 --- a/t/21-relations.t +++ b/t/21-relations.t @@ -370,6 +370,82 @@ is( ), undef ); +is( scalar $u->get_followers( uid => $uid1 ), 0 ); +is( scalar $u->get_followers( uid => $uid2 ), 0 ); +is( scalar $u->get_followees( uid => $uid1 ), 0 ); +is( scalar $u->get_followees( uid => $uid2 ), 0 ); +is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); +is( scalar $u->get_follow_requests( uid => $uid2 ), 0 ); +is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); +is( scalar $u->get_blocked_users( uid => $uid2 ), 0 ); + +$u->request_follow( + uid => $uid1, + target => $uid2 +); +$u->accept_follow_request( + uid => $uid2, + applicant => $uid1 +); + +is( + $u->get_relation( + uid => $uid1, + target => $uid2 + ), + 'follows' +); +is( + $u->get_relation( + uid => $uid2, + target => $uid1 + ), + undef +); +is( scalar $u->get_followers( uid => $uid1 ), 0 ); +is( scalar $u->get_followers( uid => $uid2 ), 1 ); +is( scalar $u->get_followees( uid => $uid1 ), 1 ); +is( scalar $u->get_followees( uid => $uid2 ), 0 ); +is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); +is( scalar $u->get_follow_requests( uid => $uid2 ), 0 ); +is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); +is( scalar $u->get_blocked_users( uid => $uid2 ), 0 ); +is_deeply( + [ $u->get_followers( uid => $uid2 ) ], + [ { id => $uid1, name => 'test1' } ] +); +is_deeply( + [ $u->get_followees( uid => $uid1 ) ], + [ { id => $uid2, name => 'test2' } ] +); + +$u->unfollow( + uid => $uid1, + target => $uid2 +); + +is( + $u->get_relation( + uid => $uid1, + target => $uid2 + ), + undef +); +is( + $u->get_relation( + uid => $uid2, + target => $uid1 + ), + undef +); +is( scalar $u->get_followers( uid => $uid1 ), 0 ); +is( scalar $u->get_followers( uid => $uid2 ), 0 ); +is( scalar $u->get_followees( uid => $uid1 ), 0 ); +is( scalar $u->get_followees( uid => $uid2 ), 0 ); +is( scalar $u->get_follow_requests( uid => $uid1 ), 0 ); +is( scalar $u->get_follow_requests( uid => $uid2 ), 0 ); +is( scalar $u->get_blocked_users( uid => $uid1 ), 0 ); +is( scalar $u->get_blocked_users( uid => $uid2 ), 0 ); $t->app->pg->db->query('drop schema travelynx_test_21 cascade'); done_testing(); |