Skip to content

Commit

Permalink
Merge pull request hngprojects#404 from Ibrahim4Grace/feat/contact-us
Browse files Browse the repository at this point in the history
fix:  resolved entity id issue
  • Loading branch information
AdeGneus authored Jul 31, 2024
2 parents 7601748 + ded34be commit 16ac0cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 87 deletions.
6 changes: 3 additions & 3 deletions src/models/contact-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -12,7 +12,7 @@ export class Contact {
email!: string;

@Column({ type: "varchar", length: 20 })
phoneNumber!: number;
phoneNumber!: string;

@Column({ type: "text" })
message!: string;
Expand Down
84 changes: 0 additions & 84 deletions src/test/contactValidator.spec.ts
Original file line number Diff line number Diff line change
@@ -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: '[email protected]',
// 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: '[email protected]',
// 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: '[email protected]',
// 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: '[email protected]',
// 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: '[email protected]',
// 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", () => {
Expand Down

0 comments on commit 16ac0cd

Please sign in to comment.