]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/utils/follows.ts
Better view counter
[github/Chocobozzz/PeerTube.git] / server / tests / utils / follows.ts
index cffc1648fac0ccd4a8a48eee2a67a12e32ca5bec..b88776011e590f4235782b60a806f101062305b1 100644 (file)
@@ -39,8 +39,17 @@ async function follow (follower: string, following: string[], accessToken: strin
     .send({ 'hosts': followingHosts })
     .expect(expectedStatus)
 
-  // Wait request propagation
-  await wait(20000)
+  return res
+}
+
+async function unfollow (url: string, accessToken: string, id: number, expectedStatus = 204) {
+  const path = '/api/v1/server/following/' + id
+
+  const res = await request(url)
+    .delete(path)
+    .set('Accept', 'application/json')
+    .set('Authorization', 'Bearer ' + accessToken)
+    .expect(expectedStatus)
 
   return res
 }
@@ -51,6 +60,9 @@ async function doubleFollow (server1: ServerInfo, server2: ServerInfo) {
     follow(server2.url, [ server1.url ], server2.accessToken)
   ])
 
+  // Wait request propagation
+  await wait(20000)
+
   return true
 }
 
@@ -59,6 +71,7 @@ async function doubleFollow (server1: ServerInfo, server2: ServerInfo) {
 export {
   getFollowersListPaginationAndSort,
   getFollowingListPaginationAndSort,
+  unfollow,
   follow,
   doubleFollow
 }