Skip to content

Commit

Permalink
fix: test cases added for the new patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
ss-nikunj committed Sep 27, 2024
1 parent 3730880 commit 0972223
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/types/Patterns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
isCountryCode,
isClientID,
isPersonName,
isSearchUserEmail,
} from './Patterns'

const TESTDATA = {
Expand Down Expand Up @@ -214,6 +215,23 @@ const TESTDATA = {
valid: ['sa-12', 'JSSS', 'Julia12'],
invalid: ['&^%#@', '!', 'hash &*^#$'],
},
EMAIL_SEARCH: {
valid: [
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
],
invalid: ['()*&^%$#/\\?><,`~'],
},
}

describe('Input Pattern Tests', () => {
Expand Down Expand Up @@ -304,4 +322,13 @@ describe('Input Pattern Tests', () => {
expect(isClientID(expr)).toBe(false)
})
})

it('Validate email search for users', () => {
TESTDATA.EMAIL_SEARCH.valid.forEach((expr) => {
expect(isSearchUserEmail(expr)).toBe(true)
})
TESTDATA.EMAIL_SEARCH.invalid.forEach((expr) => {
expect(isSearchUserEmail(expr)).toBe(false)
})
})
})
2 changes: 2 additions & 0 deletions src/types/Patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,7 @@ export const isCompanyVies = (expr: string) =>
Patterns.companyData.VIES.test(expr)
export const isPostalCode = (expr: string) =>
Patterns.companyData.POSTAL_CODE.test(expr)
export const isSearchUserEmail = (expr: string) =>
Patterns.EMAIL_SEARCH.test(expr)

export default Patterns

0 comments on commit 0972223

Please sign in to comment.