Followed @mattwr18's suggestions here:

https://github.com/Human-Connection/Human-Connection/pull/952#pullrequestreview-269406016
This commit is contained in:
Robert Schäfer 2019-08-01 12:20:33 +02:00
parent 72edf78889
commit c9e6d182ec
4 changed files with 5 additions and 6 deletions

View File

@ -4,7 +4,7 @@ const contentWithMentions =
'<p>Something inspirational about <a href="/profile/u2" class="not-a-mention" data-mention-id="bobs-id" target="_blank">@bob-der-baumeister</a> and <a href="/profile/u3/jenny-rostock" class="mention" data-mention-id="u3" target="_blank">@jenny-rostock</a>.</p>'
const contentEmptyMentions =
'<p>Something inspirational about <a href="/profile/u2" data-mention-id="" target="_blank">@bob-der-baumeister</a> and <a href="/profile/u3/jenny-rostock" class="mention" data-mention-id target="_blank">@jenny-rostock</a>.</p>'
const contentWithLinks =
const contentWithPlainLinks =
'<p>Something inspirational about <a class="mention" href="/profile/u2" target="_blank">@bob-der-baumeister</a> and <a href="/profile/u3" target="_blank">@jenny-rostock</a>.</p>'
describe('extractMentionedUsers', () => {
@ -15,7 +15,7 @@ describe('extractMentionedUsers', () => {
})
it('ignores links without .mention class', () => {
expect(extractMentionedUsers(contentWithLinks)).toEqual([])
expect(extractMentionedUsers(contentWithPlainLinks)).toEqual([])
})
describe('given a link with .mention class and `data-mention-id` attribute ', () => {

View File

@ -9,7 +9,6 @@ function clean(dirty) {
return dirty
}
// Convert embeds to a-tags
dirty = linkifyHtml(dirty)
dirty = sanitizeHtml(dirty, {
allowedTags: [

View File

@ -23,7 +23,7 @@ const plugins = [
]
helpers.init({ plugins })
const users = [{ id: 1, slug: 'peter' }, { id: 1, slug: 'sandra' }, { id: 1, slug: 'jane' }]
const users = [{ id: 1, slug: 'peter' }, { id: 2, slug: 'sandra' }, { id: 3, slug: 'jane' }]
storiesOf('Editor', module)
.addDecorator(withA11y)
@ -93,7 +93,7 @@ storiesOf('Editor', module)
content: `
<p>
Here you can mention people like
<a class="mention" href="/profile/1" target="_blank" contenteditable="false">@sandra</a> and others.
<a class="mention" data-mention-id="2" href="/profile/1" target="_blank" contenteditable="false">@sandra</a> and others.
Try it out!
</p>
`,

View File

@ -29,7 +29,7 @@ describe('defaultExtensions', () => {
describe('`content` contains a mentioning', () => {
beforeEach(() => {
content =
'<p>This is a post content mentioning <a class="mention" href="/profile/f0628376-e692-4167-bdb4-d521de5a014f" target="_blank">@alicia-luettgen</a>.</p>'
'<p>This is a post content mentioning <a class="mention" data-mention-id="alicias-id" href="/profile/f0628376-e692-4167-bdb4-d521de5a014f" target="_blank">@alicia-luettgen</a>.</p>'
})
it('renders mentioning as link', () => {