Refactor part 2
This commit is contained in:
parent
e21a807fb3
commit
80196b732a
9 changed files with 78 additions and 25 deletions
|
|
@ -91,6 +91,10 @@ test("can get user", async () => {
|
|||
assert.equal(response.id, state.userId);
|
||||
assert.equal(response.username, state.username);
|
||||
assert.equal(response.email, state.email);
|
||||
assert.equal(response.description, null);
|
||||
assert.equal(response.admin, false);
|
||||
assert.notEqual(response.registerDate, undefined);
|
||||
assert.notEqual(response.lastLogin, undefined);
|
||||
});
|
||||
|
||||
test("can modify user", async () => {
|
||||
|
|
@ -113,6 +117,9 @@ test("can modify user", async () => {
|
|||
assert.equal(responseGet.id, state.userId);
|
||||
assert.equal(responseGet.email, state.email);
|
||||
assert.equal(responseGet.description, state.description);
|
||||
assert.equal(responseGet.admin, false);
|
||||
assert.notEqual(responseGet.registerDate, undefined);
|
||||
assert.notEqual(responseGet.lastLogin, undefined);
|
||||
});
|
||||
|
||||
test("can get user sessions", async () => {
|
||||
|
|
|
|||
|
|
@ -71,11 +71,13 @@ test("can create community", async () => {
|
|||
assert.equal(responseCreate.name, state.communityName);
|
||||
assert.equal(responseCreate.description, state.communityDescription);
|
||||
assert.equal(responseCreate.ownerId, state.userId1);
|
||||
assert.notEqual(responseCreate.creationDate, undefined);
|
||||
|
||||
const responseGet = await apiGet(`community/${state.communityId}`);
|
||||
assert.equal(responseGet.name, state.communityName);
|
||||
assert.equal(responseGet.description, state.communityDescription);
|
||||
assert.equal(responseGet.ownerId, state.userId1);
|
||||
assert.notEqual(responseGet.creationDate, undefined);
|
||||
});
|
||||
|
||||
test("shouldn't be able to create invite", async () => {
|
||||
|
|
@ -133,7 +135,7 @@ test("can accept invite", async () => {
|
|||
|
||||
assert.equal(responseGet.id, state.communityId);
|
||||
assert.equal(responseGet.name, state.communityName);
|
||||
assert.equal(responseGet.members.length === 2, true);
|
||||
assert.equal(responseGet.members.length, 2);
|
||||
});
|
||||
|
||||
test("can get user communities", async () => {
|
||||
|
|
@ -143,7 +145,7 @@ test("can get user communities", async () => {
|
|||
);
|
||||
|
||||
assert.equal(response.id, state.userId2);
|
||||
assert.equal(response.communities.length === 1, true);
|
||||
assert.equal(response.communities.length, 1);
|
||||
assert.equal(response.communities[0].id, state.communityId);
|
||||
assert.equal(response.communities[0].name, state.communityName);
|
||||
assert.equal(
|
||||
|
|
@ -193,11 +195,13 @@ test("shouldn't be able to get roles", async () => {
|
|||
|
||||
test("can create channel", async () => {
|
||||
state.channelName = "Test Channel";
|
||||
state.channelDescription = "Test Channel Desc";
|
||||
|
||||
const response = await apiPost(
|
||||
`channel`,
|
||||
{
|
||||
name: state.channelName,
|
||||
description: state.channelDescription,
|
||||
communityId: state.communityId,
|
||||
},
|
||||
state.token1,
|
||||
|
|
@ -205,18 +209,22 @@ test("can create channel", async () => {
|
|||
|
||||
assert.equal(validate(response.id), true);
|
||||
assert.equal(response.name, state.channelName);
|
||||
assert.equal(response.description, state.channelDescription);
|
||||
assert.equal(response.communityId, state.communityId);
|
||||
assert.notEqual(response.creationDate, undefined);
|
||||
|
||||
state.channelId = response.id;
|
||||
});
|
||||
|
||||
test("can create role", async () => {
|
||||
state.roleName = "Test Role";
|
||||
state.roleDescription = "Test Role Desc";
|
||||
|
||||
const response = await apiPost(
|
||||
`role`,
|
||||
{
|
||||
name: state.roleName,
|
||||
description: state.roleDescription,
|
||||
communityId: state.communityId,
|
||||
permissions: ["MEMBERS_READ", "CHANNELS_READ", "ROLES_READ"],
|
||||
},
|
||||
|
|
@ -225,7 +233,10 @@ test("can create role", async () => {
|
|||
|
||||
assert.equal(validate(response.id), true);
|
||||
assert.equal(response.name, state.roleName);
|
||||
assert.equal(response.description, state.roleDescription);
|
||||
assert.equal(response.communityId, state.communityId);
|
||||
assert.equal(response.permissions.length, 3);
|
||||
assert.notEqual(response.creationDate, undefined);
|
||||
|
||||
state.roleId = response.id;
|
||||
});
|
||||
|
|
@ -253,7 +264,7 @@ test("can get members", async () => {
|
|||
|
||||
assert.equal(response.id, state.communityId);
|
||||
assert.equal(response.name, state.communityName);
|
||||
assert.equal(response.members.length === 2, true);
|
||||
assert.equal(response.members.length, 2);
|
||||
});
|
||||
|
||||
test("can get channels", async () => {
|
||||
|
|
@ -264,7 +275,7 @@ test("can get channels", async () => {
|
|||
|
||||
assert.equal(response.id, state.communityId);
|
||||
assert.equal(response.name, state.communityName);
|
||||
assert.equal(response.channels.length === 1, true);
|
||||
assert.equal(response.channels.length, 1);
|
||||
});
|
||||
|
||||
test("can get roles", async () => {
|
||||
|
|
@ -275,7 +286,7 @@ test("can get roles", async () => {
|
|||
|
||||
assert.equal(response.id, state.communityId);
|
||||
assert.equal(response.name, state.communityName);
|
||||
assert.equal(response.roles.length === 1, true);
|
||||
assert.equal(response.roles.length, 1);
|
||||
});
|
||||
|
||||
test("can get permissions", async () => {
|
||||
|
|
@ -283,8 +294,11 @@ test("can get permissions", async () => {
|
|||
|
||||
assert.equal(response.id, state.roleId);
|
||||
assert.equal(response.name, state.roleName);
|
||||
assert.equal(response.description, state.roleDescription);
|
||||
assert.equal(response.communityId, state.communityId);
|
||||
assert.equal(response.permissions.length === 3, true);
|
||||
assert.equal(response.permissions.length, 3);
|
||||
assert.equal(response.permissions[1], "CHANNELS_READ");
|
||||
assert.notEqual(response.creationDate, undefined);
|
||||
});
|
||||
|
||||
test("can unassign role from user", async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue