diff options
Diffstat (limited to 'ui/src/api_tests/api.spec.ts')
-rw-r--r-- | ui/src/api_tests/api.spec.ts | 44 |
1 files changed, 44 insertions, 0 deletions
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'); }); }); |