-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
696ce2b
commit 6d3ed14
Showing
2 changed files
with
15 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import emailValidator from '../src/index.js'; | ||
|
||
describe('Email Validator', () => { | ||
// Testing with MX record check enabled | ||
describe('with MX record check', () => { | ||
test('should validate correct email format and MX record exists', async () => { | ||
expect(await emailValidator('[email protected]')).toBe(true); | ||
|
@@ -10,9 +9,15 @@ describe('Email Validator', () => { | |
test('should reject email from domain without MX records', async () => { | ||
expect(await emailValidator('[email protected]')).toBe(false); | ||
}); | ||
|
||
test('should reject non-string inputs', async () => { | ||
expect(await emailValidator(undefined)).toBe(false); | ||
expect(await emailValidator(null)).toBe(false); | ||
expect(await emailValidator(1234)).toBe(false); | ||
expect(await emailValidator({})).toBe(false); | ||
}); | ||
}); | ||
|
||
// Testing without MX record check | ||
describe('without MX record check', () => { | ||
test('should validate correct email format regardless of MX records', async () => { | ||
expect(await emailValidator('[email protected]', false)).toBe(true); | ||
|
@@ -25,5 +30,12 @@ describe('Email Validator', () => { | |
test('should validate email from domain without MX records', async () => { | ||
expect(await emailValidator('[email protected]', false)).toBe(true); | ||
}); | ||
|
||
test('should reject non-string inputs', async () => { | ||
expect(await emailValidator(undefined, false)).toBe(false); | ||
expect(await emailValidator(null, false)).toBe(false); | ||
expect(await emailValidator(1234, false)).toBe(false); | ||
expect(await emailValidator({}, false)).toBe(false); | ||
}); | ||
}); | ||
}); |