Skip to content

Commit

Permalink
resolved unit test error
Browse files Browse the repository at this point in the history
  • Loading branch information
br41nslug committed Jun 3, 2024
1 parent d8a26ed commit 13ce519
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
4 changes: 2 additions & 2 deletions api/src/services/roles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,11 @@ describe('Integration Tests', () => {
// "as any" are needed since these are private methods
checkForOtherAdminRolesSpy = vi
.spyOn(RolesService.prototype as any, 'checkForOtherAdminRoles')
.mockResolvedValueOnce(true);
.mockResolvedValue(true);

checkForOtherAdminUsersSpy = vi
.spyOn(RolesService.prototype as any, 'checkForOtherAdminUsers')
.mockResolvedValueOnce(true);
.mockResolvedValue(true);
});

afterEach(() => {
Expand Down
12 changes: 2 additions & 10 deletions api/src/services/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,19 +354,11 @@ export class RolesService extends ItemsService {
}

const primaryKeyField = this.schema.collections[this.collection]!.primary;
const updatedKeys = data.map((item) => item[primaryKeyField]);
const setsToNoAdmin = data.some((item) => item['admin_access'] === false);

try {
if (setsToNoAdmin) {
await this.checkForOtherAdminRoles(updatedKeys);
}
} catch (err: any) {
opts.preMutationError = err;
if (!opts.mutationTracker) {
opts.mutationTracker = this.createMutationTracker();
}

if (!opts.mutationTracker) opts.mutationTracker = this.createMutationTracker();

const keys: PrimaryKey[] = [];

try {
Expand Down

0 comments on commit 13ce519

Please sign in to comment.