Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juliannemarik committed Aug 29, 2023
1 parent 70c3f6a commit 4bf3c92
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async function searchGroupMembers(
// over the includes and requestOptions
const fn = (member: IGroupMember) => {
return memberToSearchResult(
{ ...member, isOwner: resp.owner?.username === member.username },
{ ...member, isOwner: resp.owner.username === member.username },
searchOptions.include,
searchOptions.requestOptions
);
Expand Down
48 changes: 48 additions & 0 deletions packages/common/test/users/view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,53 @@ describe("user view module:", () => {
expect(result.title).toBe(`@${USER_HUB_SEARCH_RESULT.owner}`);
expect(result.source).toBeFalsy();
});
describe("membership badges", () => {
it("adds an owner badge if the user is the group owner", () => {
const GROUP_MEMBER_RESULT = cloneObject(USER_HUB_SEARCH_RESULT);
GROUP_MEMBER_RESULT.isOwner = true;
GROUP_MEMBER_RESULT.memberType = "admin";

const result = userResultToCardModel(GROUP_MEMBER_RESULT);

expect(result.badges).toEqual([
{
icon: "user-key",
color: "gray",
showLabel: false,
tooltip: { i18nKey: "memberBadges.owner" },
},
]);
});
it("adds an amin badge if the user is a group admin", () => {
const GROUP_MEMBER_RESULT = cloneObject(USER_HUB_SEARCH_RESULT);
GROUP_MEMBER_RESULT.memberType = "admin";

const result = userResultToCardModel(GROUP_MEMBER_RESULT);

expect(result.badges).toEqual([
{
icon: "user-up",
color: "gray",
showLabel: false,
tooltip: { i18nKey: "memberBadges.admin" },
},
]);
});
it("adds a member badge if the user is a group member", () => {
const GROUP_MEMBER_RESULT = cloneObject(USER_HUB_SEARCH_RESULT);
GROUP_MEMBER_RESULT.memberType = "member";

const result = userResultToCardModel(GROUP_MEMBER_RESULT);

expect(result.badges).toEqual([
{
icon: "user",
color: "gray",
showLabel: false,
tooltip: { i18nKey: "memberBadges.member" },
},
]);
});
});
});
});

0 comments on commit 4bf3c92

Please sign in to comment.