Skip to content

Commit

Permalink
Merge pull request #1479 from kianamcc/convertdoitolink-tests
Browse files Browse the repository at this point in the history
convertDoiToLink tests
  • Loading branch information
kianamcc authored Jan 3, 2025
2 parents e88e7b4 + 4d6c6f6 commit 375f244
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseSynId } from './RegularExpressions'
import { parseSynId, convertDoiToLink } from './RegularExpressions'

describe('RegularExpressions', () => {
describe('parseSynId', () => {
Expand All @@ -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('')
})
})
})

0 comments on commit 375f244

Please sign in to comment.