Skip to content

Commit

Permalink
naming convention fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sadabnepal committed May 28, 2024
1 parent 495ad68 commit ae2a4f6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions tests/data/faker.ts
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions tests/payload/mutation.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions tests/specs/goRestTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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('----------------------------');
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
19 changes: 9 additions & 10 deletions tests/types/users.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
export type genderType = 'male' | 'female';

export type statusType = 'active' | 'inactive';

export interface IUserOmittedID extends Omit<IUser, 'id'> { }
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 {
Expand All @@ -19,19 +16,21 @@ export interface IUsers {
}
}

export interface IUserCreate {
export interface IUserCreateRequest extends Omit<IUser, 'id'> { }

export interface IUserCreateResponse {
createUser: {
user: IUser
}
}

export interface IUserUpdate {
export interface IUserUpdateResponse {
updateUser: {
user: IUser
}
}

export interface IUserDelete {
export interface IUserDeleteResponse {
deleteUser: {
user: IUser
}
Expand Down

0 comments on commit ae2a4f6

Please sign in to comment.