From ae2a4f64cf0348d162f717f4378a19b79c6d479d Mon Sep 17 00:00:00 2001 From: MD SADAB SAQIB Date: Tue, 28 May 2024 21:50:44 +1000 Subject: [PATCH] naming convention fixes --- tests/data/faker.ts | 4 ++-- tests/payload/mutation.ts | 4 ++-- tests/specs/goRestTests.ts | 8 ++++---- tests/types/users.ts | 19 +++++++++---------- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/tests/data/faker.ts b/tests/data/faker.ts index 2dc54c7..0bf8f5b 100644 --- a/tests/data/faker.ts +++ b/tests/data/faker.ts @@ -1,7 +1,7 @@ import { faker } from '@faker-js/faker'; -import { IUser, IUserOmittedID } from 'types/users'; +import { IUser, IUserCreateRequest } from 'types/users'; -export const createUserData: IUserOmittedID = { +export const createUserData: IUserCreateRequest = { name: faker.person.fullName(), gender: faker.person.sexType(), email: faker.internet.email(), diff --git a/tests/payload/mutation.ts b/tests/payload/mutation.ts index 1d97e28..d4f70a6 100644 --- a/tests/payload/mutation.ts +++ b/tests/payload/mutation.ts @@ -1,7 +1,7 @@ -import { IUser, IUserOmittedID } from 'types/users'; +import { IUser, IUserCreateRequest } from 'types/users'; import { userFragments, userResponseFields } from './fragments'; -export const createUserPayload = (data: IUserOmittedID) => { +export const createUserPayload = (data: IUserCreateRequest) => { return ` ${userFragments} mutation { diff --git a/tests/specs/goRestTests.ts b/tests/specs/goRestTests.ts index fcfd8a1..863ea2c 100644 --- a/tests/specs/goRestTests.ts +++ b/tests/specs/goRestTests.ts @@ -5,7 +5,7 @@ import { mutateGraphQl, queryGraphQl } from 'helper/apiUtils'; import { queryUsers } from 'payload/directives'; import { createUserPayload, deleteUserPayload, updateUserPayload } from 'payload/mutation'; import { queryAllUserPayload, queryUserByIdPayload } from 'payload/queries'; -import { INonExistingUserError, IUser, IUserCreate, IUserDelete, IUserUpdate, IUsers } from 'types/users'; +import { INonExistingUserError, IUser, IUserCreateResponse, IUserDeleteResponse, IUserUpdateResponse, IUsers } from 'types/users'; config(); const TOKEN = process.env.GO_RES_USER_TOKEN; @@ -41,7 +41,7 @@ describe('go rest graphql tests', () => { const response = await mutateGraphQl(TOKEN, createUserPayload(createRandomUser)); expect(response.statusCode).equal(200); - const responseData: IUserCreate = response.body.data; + const responseData: IUserCreateResponse = response.body.data; userId = responseData.createUser.user.id; console.log('----------------------------'); @@ -84,7 +84,7 @@ describe('go rest graphql tests', () => { expect(response.body.data).not.undefined; - const responseData: IUserUpdate = response.body.data; + const responseData: IUserUpdateResponse = response.body.data; console.log('----------------------------'); console.log('updated user => id: ', userId); @@ -105,7 +105,7 @@ describe('go rest graphql tests', () => { expect(response.body.data).not.undefined; - const responseData: IUserDelete = response.body.data; + const responseData: IUserDeleteResponse = response.body.data; console.log('----------------------------'); console.log('deleted user => id: ', userId); diff --git a/tests/types/users.ts b/tests/types/users.ts index b385c57..1ef2945 100644 --- a/tests/types/users.ts +++ b/tests/types/users.ts @@ -1,15 +1,12 @@ -export type genderType = 'male' | 'female'; - -export type statusType = 'active' | 'inactive'; - -export interface IUserOmittedID extends Omit { } +type Gender = 'male' | 'female'; +type Status = 'active' | 'inactive'; export interface IUser { id: number; name: string; email: string; - gender: genderType; - status: statusType; + gender: Gender; + status: Status; } export interface IUsers { @@ -19,19 +16,21 @@ export interface IUsers { } } -export interface IUserCreate { +export interface IUserCreateRequest extends Omit { } + +export interface IUserCreateResponse { createUser: { user: IUser } } -export interface IUserUpdate { +export interface IUserUpdateResponse { updateUser: { user: IUser } } -export interface IUserDelete { +export interface IUserDeleteResponse { deleteUser: { user: IUser }