Skip to content

Commit 6b820f3

Browse files
committed
Migrate doctest for ValidateEmail.js
1 parent dd619c9 commit 6b820f3

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

String/ValidateEmail.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
1-
/*
2-
Function that takes a string input and return either true or false
3-
If it is a valid email address
4-
*/
5-
6-
/*
7-
* Doctests
8-
*
9-
* > validateEmail('[email protected]')
10-
* true
11-
* > validateEmail('[email protected]')
12-
* true
13-
* > validateEmail('mahfoudh.arous.com')
14-
* false
15-
* > validateEmail('')
16-
* ! TypeError
17-
* > validateEmail(null)
18-
* ! TypeError
19-
*/
1+
/**
2+
* Returns whether the given string is a valid email address or not.
3+
*/
204
const validateEmail = (str) => {
215
if (str === '' || str === null) {
226
throw new TypeError('Email Address String Null or Empty.')

String/test/ValidateEmail.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ describe('Validation of an Email Address', () => {
1919

2020
it('expects to throw a type error', () => {
2121
expect(() => { validateEmail('') }).toThrow('Email Address String Null or Empty.')
22+
expect(() => { validateEmail(null) }).toThrow('Email Address String Null or Empty.')
2223
})
2324
})

0 commit comments

Comments
 (0)