import extractMentionedUsers from './extractMentionedUsers' describe('extractMentionedUsers', () => { describe('content undefined', () => { it('returns empty array', () => { expect(extractMentionedUsers()).toEqual([]) }) }) describe('searches through links', () => { it('ignores links without .mention class', () => { const content = '

Something inspirational about @bob-der-baumeister and @jenny-rostock.

' expect(extractMentionedUsers(content)).toEqual([]) }) describe('given a link with .mention class', () => { it('extracts ids', () => { const content = '

Something inspirational about @bob-der-baumeister and @jenny-rostock.

' expect(extractMentionedUsers(content)).toEqual(['u2', 'u3']) }) describe('handles links', () => { it('with slug and id', () => { const content = '

Something inspirational about @bob-der-baumeister and @jenny-rostock.

' expect(extractMentionedUsers(content)).toEqual(['u2', 'u3']) }) it('with domains', () => { const content = '

Something inspirational about @bob-der-baumeister and @jenny-rostock.

' expect(extractMentionedUsers(content)).toEqual(['u2', 'u3']) }) it('special characters', () => { const content = '

Something inspirational about @bob-der-baumeister and @jenny-rostock.

' expect(extractMentionedUsers(content)).toEqual(['u!*(),2', 'u.~-3']) }) }) describe('does not crash if', () => { it('`href` contains no user id', () => { const content = '

Something inspirational about @bob-der-baumeister and @jenny-rostock.

' expect(extractMentionedUsers(content)).toEqual([]) }) it('`href` is empty or invalid', () => { const content = '

Something inspirational about @bob-der-baumeister and @jenny-rostock.

' expect(extractMentionedUsers(content)).toEqual([]) }) }) }) }) })