-
-
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
2b2c30e
commit c9aabd8
Showing
3 changed files
with
19 additions
and
2 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
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 |
---|---|---|
|
@@ -19,6 +19,22 @@ describe('Match', () => { | |
expect(matches[1]).toBe('[email protected]'); | ||
}); | ||
|
||
it('Should convert regex to global and return matches when it exists', async () => { | ||
const data = [ | ||
'this is a line with an email: [email protected]', | ||
'this e-mail [email protected] is on 2nd line and is duplicated: [email protected]', | ||
]; | ||
|
||
const matches = await Match(/(\S+@\w+\.\w+)/, data); | ||
|
||
expect(Array.isArray(matches)).toBe(true); | ||
expect(matches).toStrictEqual([ | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
]); | ||
}); | ||
|
||
it('Should remove duplicated matches and return when it exists', async () => { | ||
const data = [ | ||
'this is a line with an email: [email protected]', | ||
|