mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 09:39:09 +00:00
fix tests
This commit is contained in:
parent
1dd910a5f6
commit
8ea7746dd5
6 changed files with 34 additions and 13 deletions
|
@ -1,8 +1,8 @@
|
|||
import { hasPermission, permissions, hasPermissionOrAdmin } from './hasPermission';
|
||||
import { Role } from 'roleypoly/rpc/shared';
|
||||
import { Role } from 'roleypoly/common/types';
|
||||
import { guildRoles } from 'roleypoly/common/types/storyData';
|
||||
|
||||
const roles: Role.AsObject[] = [
|
||||
const roles: Role[] = [
|
||||
{
|
||||
...guildRoles.rolesList[0],
|
||||
permissions: permissions.ADMINISTRATOR,
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
import { Role } from 'roleypoly/rpc/shared';
|
||||
import { Role } from 'roleypoly/common/types';
|
||||
|
||||
export const hasPermission = (roles: Role.AsObject[], permission: number): boolean => {
|
||||
export const hasPermission = (roles: Role[], permission: number): boolean => {
|
||||
const aggregateRoles = roles.reduce((acc, role) => acc | role.permissions, 0);
|
||||
return (aggregateRoles & permission) === permission;
|
||||
};
|
||||
|
||||
export const hasPermissionOrAdmin = (
|
||||
roles: Role.AsObject[],
|
||||
permission: number
|
||||
): boolean => hasPermission(roles, permission | permissions.ADMINISTRATOR);
|
||||
export const hasPermissionOrAdmin = (roles: Role[], permission: number): boolean =>
|
||||
hasPermission(roles, permission | permissions.ADMINISTRATOR);
|
||||
|
||||
export const permissions = {
|
||||
CREATE_INSTANT_INVITE: 0x1,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
jest.unmock('roleypoly/src/design-system/atoms/text-input');
|
||||
jest.unmock('roleypoly/design-system/atoms/text-input');
|
||||
jest.unmock('./PreauthSecretCode');
|
||||
|
||||
import { Button } from 'roleypoly/design-system/atoms/button';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
jest.unmock('roleypoly/src/design-system/atoms/role')
|
||||
.unmock('roleypoly/src/design-system/atoms/button')
|
||||
.unmock('roleypoly/src/design-system/molecules/picker-category')
|
||||
.unmock('roleypoly/src/design-system/organisms/role-picker');
|
||||
jest.unmock('roleypoly/design-system/atoms/role')
|
||||
.unmock('roleypoly/design-system/atoms/button')
|
||||
.unmock('roleypoly/design-system/molecules/picker-category')
|
||||
.unmock('roleypoly/design-system/organisms/role-picker');
|
||||
|
||||
import { shallow } from 'enzyme';
|
||||
import * as React from 'react';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue