]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/utils/follows.ts
Add follow tests
[github/Chocobozzz/PeerTube.git] / server / tests / utils / follows.ts
index 618436b3cfb1ad1563a0ffd680723dc3cf640b99..b88776011e590f4235782b60a806f101062305b1 100644 (file)
@@ -42,6 +42,18 @@ async function follow (follower: string, following: string[], accessToken: strin
   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
+}
+
 async function doubleFollow (server1: ServerInfo, server2: ServerInfo) {
   await Promise.all([
     follow(server1.url, [ server2.url ], server1.accessToken),
@@ -59,6 +71,7 @@ async function doubleFollow (server1: ServerInfo, server2: ServerInfo) {
 export {
   getFollowersListPaginationAndSort,
   getFollowingListPaginationAndSort,
+  unfollow,
   follow,
   doubleFollow
 }