diff --git a/src/models/contact-us.ts b/src/models/contact-us.ts index 3db1b72e..2d816ad9 100644 --- a/src/models/contact-us.ts +++ b/src/models/contact-us.ts @@ -2,8 +2,8 @@ import { Entity, PrimaryGeneratedColumn, Column } from "typeorm"; @Entity() export class Contact { - @PrimaryGeneratedColumn() - id!: number; + @PrimaryGeneratedColumn("uuid") + id!: string; @Column({ type: "varchar", length: 100 }) name!: string; @@ -12,7 +12,7 @@ export class Contact { email!: string; @Column({ type: "varchar", length: 20 }) - phoneNumber!: number; + phoneNumber!: string; @Column({ type: "text" }) message!: string; diff --git a/src/test/contactValidator.spec.ts b/src/test/contactValidator.spec.ts index ac03ac76..f4fc10e4 100644 --- a/src/test/contactValidator.spec.ts +++ b/src/test/contactValidator.spec.ts @@ -1,87 +1,3 @@ -// import { validateContact } from '../utils/contactValidator'; - -// describe('validateContact', () => { -// it('should return no errors for valid contact data', () => { -// const validData = { -// name: 'Korede Akorede', -// email: 'ibraim@gmail.com', -// phoneNumber: '1234567890', -// message: 'I am a backend dev', -// }; - -// const errors = validateContact(validData); -// expect(errors).toEqual([]); -// }); - -// it('should return error for missing name', () => { -// const invalidData = { -// name: '', -// email: 'ibraim@gmail.com', -// phoneNumber: '1234567890', -// message: 'I am a backend dev', -// }; - -// const errors = validateContact(invalidData); -// expect(errors).toContain( -// 'Please enter your name. It should be less than 100 characters.' -// ); -// }); - -// it('should return error for invalid email format', () => { -// const invalidData = { -// name: 'Korede Akorede', -// email: 'invalid-email', -// phoneNumber: '1234567890', -// message: 'I am a backend dev', -// }; - -// const errors = validateContact(invalidData); -// expect(errors).toContain('Please enter a valid email address.'); -// }); - -// it('should return error for invalid phone number format', () => { -// const invalidData = { -// name: 'Korede Akorede', -// email: 'ibraim@gmail.com', -// phoneNumber: '123', -// message: 'I am a backend dev', -// }; - -// const errors = validateContact(invalidData); -// expect(errors).toContain( -// 'Please enter a valid phone number. It should be a number with 10 to 15 digits.' -// ); -// }); - -// it('should return error for message length exceeding 250 characters', () => { -// const invalidData = { -// name: 'Korede Akorede', -// email: 'ibraim@gmail.com', -// phoneNumber: '1234567890', -// message: 'a'.repeat(251), // Message length exceeds 250 characters -// }; - -// const errors = validateContact(invalidData); -// expect(errors).toContain( -// 'Please enter your message. It should be less than 250 characters.' -// ); -// }); - -// it('should return error for phone number with non-numeric characters', () => { -// const invalidData = { -// name: 'Korede Akorede', -// email: 'ibraim@gmail.com', -// phoneNumber: '123-456-7890', -// message: 'I am a backend dev', -// }; - -// const errors = validateContact(invalidData); -// expect(errors).toContain( -// 'Please enter a valid phone number. It should be a number with 10 to 15 digits.' -// ); -// }); -// }); - import { validateContact } from "../utils/contactValidator"; describe("validateContact", () => {