diff --git a/packages/synapse-react-client/src/utils/functions/RegularExpressions.test.ts b/packages/synapse-react-client/src/utils/functions/RegularExpressions.test.ts index 13f6495c48..eb9ecac68d 100644 --- a/packages/synapse-react-client/src/utils/functions/RegularExpressions.test.ts +++ b/packages/synapse-react-client/src/utils/functions/RegularExpressions.test.ts @@ -1,4 +1,4 @@ -import { parseSynId } from './RegularExpressions' +import { parseSynId, convertDoiToLink } from './RegularExpressions' describe('RegularExpressions', () => { describe('parseSynId', () => { @@ -11,4 +11,26 @@ describe('RegularExpressions', () => { expect(parseSynId(synId)).toEqual(expected) }) }) + describe('convertDoiToLink', () => { + test('valid input', () => { + const validInput = ' 10.1000/abc123 ' + const result = convertDoiToLink(validInput) + expect(result).toBe('https://dx.doi.org/10.1000/abc123') + }) + test('empty string input', () => { + const input = '' + const result = convertDoiToLink(input) + expect(result).toBe('') + }) + test('invalid input', () => { + const invalidInput = 'not-a-valid-doi' + const result = convertDoiToLink(invalidInput) + expect(result).toBe('') + }) + test('malformed doi', () => { + const malformedDoi = '10.1000' + const result = convertDoiToLink(malformedDoi) + expect(result).toBe('') + }) + }) })