Skip to content

Commit

Permalink
fix(rbac): simplify helpers unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksandr Andriienko <[email protected]>
  • Loading branch information
AndrienkoAleksandr committed Dec 2, 2024
1 parent 847e5d9 commit fe81244
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,25 @@ export class KeycloakAdminClientMockServerv24 {
]),
listMembers: jest
.fn()
.mockResolvedValueOnce(groupMembers1.map(username => ({ username })))
// return empty list for second pagination page of the groupMembers1.
.mockResolvedValueOnce([])
// return empty list members
.mockResolvedValueOnce([])
// return empty list members
.mockResolvedValueOnce([])
.mockResolvedValueOnce(groupMembers2.map(username => ({ username }))),
.mockImplementation(
async (payload?: {
id: string;
_max?: number;
_realm?: string;
first?: number;
}) => {
const { id, first } = payload || {};
if (id === '9cf51b5d-e066-4ed8-940c-dc6da77f81a5' && first === 0) {
// biggroup - first members page
return groupMembers1.map(username => ({ username }));
}
if (id === 'bb10231b-2939-4b1a-b8bb-9249ed7b76f7' && first === 0) {
// testgroup - first members page
return groupMembers2.map(username => ({ username }));
}
return [];
},
),
};

auth = authMock;
Expand Down

0 comments on commit fe81244

Please sign in to comment.