-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #686 from software-mansion-labs/war-in/convert-men…
…tions-with-ids-to-markdown Pass extra data (fe. accountIDs) to HTMLToMarkdown method & add possibility to disable certain rules
- Loading branch information
Showing
5 changed files
with
186 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2030,6 +2030,13 @@ describe('room mentions', () => { | |
expect(parser.replace(testString)).toBe(resultString); | ||
}); | ||
|
||
test('room mention shouldn\'t be parsed when rule is disabled', () => { | ||
const testString = '*hello* @[email protected] in #room!'; | ||
const resultString = '<strong>hello</strong> <mention-user>@[email protected]</mention-user> in #room!'; | ||
const disabledRules = ['reportMentions']; | ||
expect(parser.replace(testString, {disabledRules})).toBe(resultString); | ||
}); | ||
|
||
test('room mention with italic, bold and strikethrough styles', () => { | ||
const testString = '#room' | ||
+ ' _#room_' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,7 +133,7 @@ test('Test remove style tag', () => { | |
expect(parser.htmlToText(testString)).toBe('a text'); | ||
}); | ||
|
||
test('Mention html to text', () => { | ||
test('Mention user html to text', () => { | ||
let testString = '<mention-user>@[email protected]</mention-user>'; | ||
expect(parser.htmlToText(testString)).toBe('@[email protected]'); | ||
|
||
|
@@ -145,6 +145,42 @@ test('Mention html to text', () => { | |
|
||
testString = '<mention-user>@[email protected]</mention-user>'; | ||
expect(parser.htmlToText(testString)).toBe('@[email protected]'); | ||
|
||
const extras = { | ||
accountIdToName: { | ||
'1234': '[email protected]', | ||
}, | ||
}; | ||
testString = '<mention-user accountID="1234"/>'; | ||
expect(parser.htmlToText(testString, extras)).toBe('@[email protected]'); | ||
|
||
testString = '<mention-user accountID="1234" />'; | ||
expect(parser.htmlToText(testString, extras)).toBe('@[email protected]'); | ||
}); | ||
|
||
test('Mention report html to text', () => { | ||
let testString = '<mention-report>#room-name</mention-report>'; | ||
expect(parser.htmlToText(testString)).toBe('#room-name'); | ||
|
||
testString = '<mention-report>#ROOM-NAME</mention-report>'; | ||
expect(parser.htmlToText(testString)).toBe('#ROOM-NAME'); | ||
|
||
testString = '<mention-report>#ROOM-name</mention-report>'; | ||
expect(parser.htmlToText(testString)).toBe('#ROOM-name'); | ||
|
||
testString = '<mention-report>#room-NAME</mention-report>'; | ||
expect(parser.htmlToText(testString)).toBe('#room-NAME'); | ||
|
||
const extras = { | ||
reportIdToName: { | ||
'1234': '#room-name', | ||
}, | ||
}; | ||
testString = '<mention-report reportID="1234"/>'; | ||
expect(parser.htmlToText(testString, extras)).toBe('#room-name'); | ||
|
||
testString = '<mention-report reportID="1234" />'; | ||
expect(parser.htmlToText(testString, extras)).toBe('#room-name'); | ||
}); | ||
|
||
test('Test replacement for <img> tags', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -743,7 +743,7 @@ test('Linebreak should be remained for text between code block', () => { | |
}); | ||
}); | ||
|
||
test('Mention html to markdown', () => { | ||
test('Mention user html to markdown', () => { | ||
let testString = '<mention-user>@[email protected]</mention-user>'; | ||
expect(parser.htmlToMarkdown(testString)).toBe('@[email protected]'); | ||
|
||
|
@@ -755,6 +755,42 @@ test('Mention html to markdown', () => { | |
|
||
testString = '<mention-user>@[email protected]</mention-user>'; | ||
expect(parser.htmlToMarkdown(testString)).toBe('@[email protected]'); | ||
|
||
const extras = { | ||
accountIdToName: { | ||
'1234': '[email protected]', | ||
}, | ||
}; | ||
testString = '<mention-user accountID="1234"/>'; | ||
expect(parser.htmlToMarkdown(testString, extras)).toBe('@[email protected]'); | ||
|
||
testString = '<mention-user accountID="1234" />'; | ||
expect(parser.htmlToMarkdown(testString, extras)).toBe('@[email protected]'); | ||
}); | ||
|
||
test('Mention report html to markdown', () => { | ||
let testString = '<mention-report>#room-name</mention-report>'; | ||
expect(parser.htmlToMarkdown(testString)).toBe('#room-name'); | ||
|
||
testString = '<mention-report>#ROOM-NAME</mention-report>'; | ||
expect(parser.htmlToMarkdown(testString)).toBe('#ROOM-NAME'); | ||
|
||
testString = '<mention-report>#ROOM-name</mention-report>'; | ||
expect(parser.htmlToMarkdown(testString)).toBe('#ROOM-name'); | ||
|
||
testString = '<mention-report>#room-NAME</mention-report>'; | ||
expect(parser.htmlToMarkdown(testString)).toBe('#room-NAME'); | ||
|
||
const extras = { | ||
reportIdToName: { | ||
'1234': '#room-name', | ||
}, | ||
}; | ||
testString = '<mention-report reportID="1234"/>'; | ||
expect(parser.htmlToMarkdown(testString, extras)).toBe('#room-name'); | ||
|
||
testString = '<mention-report reportID="1234" />'; | ||
expect(parser.htmlToMarkdown(testString, extras)).toBe('#room-name'); | ||
}); | ||
|
||
describe('Image tag conversion to markdown', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters