Skip to content

Commit

Permalink
Merge pull request #42 from Kilix/fix/lel-AddTestCaseInTestLinkedInUr…
Browse files Browse the repository at this point in the history
…lFormat

🐛 Fix: Change testLinkedInUrlFormat regex and add the test case
  • Loading branch information
Meilo authored Oct 12, 2021
2 parents 906959b + 94c32ac commit e8dac0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/__tests__/fieldValidators.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ it('testEmailFormat', () => {
});

describe('testLinkedInUrlFormat', () => {
it('Should return null if param url is null', () => {
const actual = testLinkedInUrlFormat(null);
expect(actual).toBe(null);
});
it('Should return notLinkedInUrl error message if param is not an url', () => {
const actual = testLinkedInUrlFormat('Bob');
expect(actual).toBe('notLinkedInUrl');
Expand All @@ -180,6 +184,9 @@ describe('testLinkedInUrlFormat', () => {
let actual = testLinkedInUrlFormat('https://www.linkedinsss.com/in/url-test/');
expect(actual).toBe('notLinkedInUrl');

actual = testLinkedInUrlFormat('https://ww.linkedin.com/in/url-test/');
expect(actual).toBe('notLinkedInUrl');

actual = testLinkedInUrlFormat('https://wwwddd.linkedin.com/in/url-test/');
expect(actual).toBe('notLinkedInUrl');

Expand Down
2 changes: 1 addition & 1 deletion src/fieldValidators.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const testEmailFormat = (value: ?string) => {
const testLinkedInUrlFormat = (value: ?string) => {
if (!value) return null;

const regexp = /(https?):(\/\/)(([w]{3}||\w\w)\.)?linkedin.com\/in\/.+/; // eslint-disable-line no-control-regex
const regexp = /(https?):(\/\/)(www\.)?linkedin.com\/in\/.+/; // eslint-disable-line no-control-regex
return regexp.test(value.trim()) ? null : 'notLinkedInUrl';
};

Expand Down

0 comments on commit e8dac0c

Please sign in to comment.