test: Add types to getUser test file

This commit is contained in:
Faruk AYDIN
2023-10-04 20:42:47 +02:00
parent b5df1a026a
commit 1683c5630a
5 changed files with 22 additions and 14 deletions

View File

@@ -1,3 +1,4 @@
import { IPermission } from '@automatisch/types';
import createRole from './role';
type PermissionParams = {
@@ -6,9 +7,11 @@ type PermissionParams = {
subject?: string;
};
const createPermission = async (params: PermissionParams = {}) => {
const createPermission = async (
params: PermissionParams = {}
): Promise<IPermission> => {
const permissionData = {
role_id: params?.roleId || (await createRole()).id,
roleId: params?.roleId || (await createRole()).id,
action: params?.action || 'read',
subject: params?.subject || 'User',
};

View File

@@ -1,9 +1,11 @@
import { IRole } from '@automatisch/types';
type RoleParams = {
name?: string;
key?: string;
};
const createRole = async (params: RoleParams = {}) => {
const createRole = async (params: RoleParams = {}): Promise<IRole> => {
params.name = params?.name || 'Viewer';
params.key = params?.key || 'viewer';

View File

@@ -10,8 +10,8 @@ type UserParams = {
const createUser = async (params: UserParams = {}) => {
const userData = {
role_id: params?.roleId || (await createRole()).id,
full_name: params?.fullName || faker.person.fullName(),
roleId: params?.roleId || (await createRole()).id,
fullName: params?.fullName || faker.person.fullName(),
email: params?.email || faker.internet.email(),
password: params?.password || faker.internet.password(),
};