Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for validateEmail.test.js #113

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions src/validateEmail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,48 @@ describe(`Function 'validateEmail':`, () => {
});

it(`should return boolean`, () => {

expect(typeof validateEmail('[email protected]')).toBe('boolean');
});

it(`should return 'true' for the valid email`, () => {
expect(validateEmail('[email protected].'))
.toBeTruthy();
});

// write more tests here
it(`should return 'false' for an email without '@'`, () => {
expect(validateEmail('testmail.com')).toBe(false);
});

it(`should return 'false' for an email with an invalid domain`, () => {
expect(validateEmail('test@mail')).toBe(false);
});

it(`should return 'false' for an email starting with a dot`, () => {
expect(validateEmail('[email protected]')).toBe(false);
});

it(`should return 'false' for an email ending with a dot`, () => {
expect(validateEmail('[email protected]')).toBe(false);
});

it(`should return 'false' for an email with double dots in
personal_info`, () => {
expect(validateEmail('[email protected]')).toBe(false);
});

it(`should return 'false' for an email with invalid characters in
personal_info`, () => {
expect(validateEmail('[email protected]')).toBe(false);
expect(validateEmail('[email protected]')).toBe(false);
});

it(`should return 'false' for an email with a domain containing
invalid characters`, () => {
expect(validateEmail('test@mail!.com')).toBe(false);
});

it(`should return 'false' for an email with a domain starting with
a hyphen`, () => {
expect(validateEmail('[email protected]')).toBe(false);
});
});