From b8b2398d32908c982635070ce1ce58eee504dc1d Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 3 May 2020 22:41:45 -0400 Subject: Adding undo follow community. --- ui/src/api_tests/api.spec.ts | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'ui/src/api_tests') diff --git a/ui/src/api_tests/api.spec.ts b/ui/src/api_tests/api.spec.ts index b25c8df5..a3826504 100644 --- a/ui/src/api_tests/api.spec.ts +++ b/ui/src/api_tests/api.spec.ts @@ -140,6 +140,50 @@ describe('main', () => { ).then(d => d.json()); expect(followedCommunitiesRes.communities[1].community_local).toBe(false); + + // Test out unfollowing + let unfollowForm: FollowCommunityForm = { + community_id: searchResponse.communities[0].id, + follow: false, + auth: lemmyAlphaAuth, + }; + + let unfollowRes: CommunityResponse = await fetch( + `${lemmyAlphaApiUrl}/community/follow`, + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: wrapper(unfollowForm), + } + ).then(d => d.json()); + + // Check that you are unsubscribed to it locally + let followedCommunitiesResAgain: GetFollowedCommunitiesResponse = await fetch( + followedCommunitiesUrl, + { + method: 'GET', + } + ).then(d => d.json()); + + expect(followedCommunitiesResAgain.communities.length).toBe(1); + + // Follow again, for other tests + let followResAgain: CommunityResponse = await fetch( + `${lemmyAlphaApiUrl}/community/follow`, + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: wrapper(followForm), + } + ).then(d => d.json()); + + // Make sure the follow response went through + expect(followResAgain.community.local).toBe(false); + expect(followResAgain.community.name).toBe('main'); }); }); -- cgit v1.2.3