Add logged user and user communities endpoint
This commit is contained in:
parent
ddcc591d12
commit
a85330e8cf
7 changed files with 180 additions and 3 deletions
|
|
@ -23,6 +23,12 @@ test("can register", async () => {
|
|||
state.userId = response.id;
|
||||
});
|
||||
|
||||
test("shouldn't be authorized to get logged user", async () => {
|
||||
const response = await apiGet(`user/logged`);
|
||||
|
||||
assert.equal(response.error, "ACCESS_DENIED");
|
||||
});
|
||||
|
||||
test("shouldn't be able to login", async () => {
|
||||
const response = await apiPost(`auth/login`, {
|
||||
username: state.username,
|
||||
|
|
@ -48,6 +54,12 @@ test("can login", async () => {
|
|||
state.token = response.token;
|
||||
});
|
||||
|
||||
test("can get logged user", async () => {
|
||||
const response = await apiGet(`user/logged`, state.token);
|
||||
|
||||
assert.equal(response.id, state.userId);
|
||||
});
|
||||
|
||||
test("shouldn't be authorized to get user", async () => {
|
||||
const response1 = await apiGet(`user/${state.userId}`);
|
||||
assert.equal(response1.error, "ACCESS_DENIED");
|
||||
|
|
|
|||
|
|
@ -121,6 +121,22 @@ test("can accept invite", async () => {
|
|||
assert.equal(responseGet.members.length === 2, true);
|
||||
});
|
||||
|
||||
test("can get user communities", async () => {
|
||||
const response = await apiGet(
|
||||
`user/${state.userId2}/communities`,
|
||||
state.token2,
|
||||
);
|
||||
|
||||
assert.equal(response.id, state.userId2);
|
||||
assert.equal(response.communities.length === 1, true);
|
||||
assert.equal(response.communities[0].id, state.communityId);
|
||||
assert.equal(response.communities[0].name, state.communityName);
|
||||
assert.equal(
|
||||
response.communities[0].description,
|
||||
state.communityDescription,
|
||||
);
|
||||
});
|
||||
|
||||
test("can get invite", async () => {
|
||||
const response = await apiGet(`invite/${state.inviteId}`);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue