summaryrefslogtreecommitdiffstats
path: root/ui/src/api_tests
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-05-03 20:34:04 -0400
committerDessalines <tyhou13@gmx.com>2020-05-03 20:34:04 -0400
commitfab22e3d8a44ecfd4ccb5a8762ea16845b1b4e1b (patch)
treefbed1bf394dca6a0976bda74839fa9ef489b3409 /ui/src/api_tests
parentdfc9637230907df73c50dddf5fd565159bb38ec5 (diff)
Add federated comment and post undo like.
Diffstat (limited to 'ui/src/api_tests')
-rw-r--r--ui/src/api_tests/api.spec.ts44
1 files changed, 42 insertions, 2 deletions
diff --git a/ui/src/api_tests/api.spec.ts b/ui/src/api_tests/api.spec.ts
index ed97174e..b25c8df5 100644
--- a/ui/src/api_tests/api.spec.ts
+++ b/ui/src/api_tests/api.spec.ts
@@ -16,6 +16,8 @@ import {
CommunityForm,
GetCommunityForm,
GetCommunityResponse,
+ CommentLikeForm,
+ CreatePostLikeForm,
} from '../interfaces';
let lemmyAlphaUrl = 'http://localhost:8540';
@@ -163,11 +165,28 @@ describe('main', () => {
}
).then(d => d.json());
+ let unlikePostForm: CreatePostLikeForm = {
+ post_id: createResponse.post.id,
+ score: 0,
+ auth: lemmyAlphaAuth,
+ };
expect(createResponse.post.name).toBe(name);
expect(createResponse.post.community_local).toBe(false);
expect(createResponse.post.creator_local).toBe(true);
expect(createResponse.post.score).toBe(1);
+ let unlikePostRes: PostResponse = await fetch(
+ `${lemmyAlphaApiUrl}/post/like`,
+ {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: wrapper(unlikePostForm),
+ }
+ ).then(d => d.json());
+ expect(unlikePostRes.post.score).toBe(0);
+
let getPostUrl = `${lemmyBetaApiUrl}/post?id=2`;
let getPostRes: GetPostResponse = await fetch(getPostUrl, {
method: 'GET',
@@ -176,7 +195,7 @@ describe('main', () => {
expect(getPostRes.post.name).toBe(name);
expect(getPostRes.post.community_local).toBe(true);
expect(getPostRes.post.creator_local).toBe(false);
- expect(getPostRes.post.score).toBe(1);
+ expect(getPostRes.post.score).toBe(0);
});
});
@@ -243,6 +262,27 @@ describe('main', () => {
expect(createResponse.comment.creator_local).toBe(true);
expect(createResponse.comment.score).toBe(1);
+ // Do an unlike, to test it
+ let unlikeCommentForm: CommentLikeForm = {
+ comment_id: createResponse.comment.id,
+ score: 0,
+ post_id: 2,
+ auth: lemmyAlphaAuth,
+ };
+
+ let unlikeCommentRes: CommentResponse = await fetch(
+ `${lemmyAlphaApiUrl}/comment/like`,
+ {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: wrapper(unlikeCommentForm),
+ }
+ ).then(d => d.json());
+
+ expect(unlikeCommentRes.comment.score).toBe(0);
+
let getPostUrl = `${lemmyBetaApiUrl}/post?id=2`;
let getPostRes: GetPostResponse = await fetch(getPostUrl, {
method: 'GET',
@@ -251,7 +291,7 @@ describe('main', () => {
expect(getPostRes.comments[0].content).toBe(content);
expect(getPostRes.comments[0].community_local).toBe(true);
expect(getPostRes.comments[0].creator_local).toBe(false);
- expect(getPostRes.comments[0].score).toBe(1);
+ expect(getPostRes.comments[0].score).toBe(0);
// Now do beta replying to that comment, as a child comment
let contentBeta = 'A child federated comment from beta';