summaryrefslogtreecommitdiffstats
path: root/ui/src/api_tests
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-05-03 22:41:45 -0400
committerDessalines <tyhou13@gmx.com>2020-05-03 22:41:45 -0400
commitb8b2398d32908c982635070ce1ce58eee504dc1d (patch)
treecff63e37ab00d71bc43e3c998b1345a308af4ff9 /ui/src/api_tests
parentfab22e3d8a44ecfd4ccb5a8762ea16845b1b4e1b (diff)
Adding undo follow community.
Diffstat (limited to 'ui/src/api_tests')
-rw-r--r--ui/src/api_tests/api.spec.ts44
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');
});
});