File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,4 +24,28 @@ describe('Parser', () => {
2424 expect ( Parser . isHTML ( '<>' ) ) . toBe ( false ) ;
2525 } ) ;
2626 } ) ;
27+
28+ describe ( 'htmlToMarkdown' , ( ) => {
29+ // These cases pin the contract relied on by DescriptionField.tsx, where the description of a saved
30+ // transaction is stored as HTML (because `getParsedComment()` runs ExpensiMark at save time) and must
31+ // be normalized back to markdown before being handed to the `shouldParseTitle` MenuItem and the
32+ // `type="markdown"` TextInput. Without this normalization, the Split details page renders raw `<a>`
33+ // tags as visible text — see https://github.com/Expensify/App/issues/87519.
34+ test ( 'converts an autolinked URL anchor back to a markdown link' , ( ) => {
35+ expect ( Parser . htmlToMarkdown ( '<a href="https://google.com" target="_blank" rel="noreferrer noopener">google.com</a>' ) ) . toBe ( '[google.com](https://google.com)' ) ;
36+ } ) ;
37+
38+ test ( 'converts ExpensiMark-emitted bold tags back to markdown asterisks' , ( ) => {
39+ expect ( Parser . htmlToMarkdown ( '<strong>hello</strong> world' ) ) . toBe ( '*hello* world' ) ;
40+ } ) ;
41+
42+ test ( 'is a no-op for plain text descriptions used by draft transactions' , ( ) => {
43+ expect ( Parser . htmlToMarkdown ( 'lunch' ) ) . toBe ( 'lunch' ) ;
44+ expect ( Parser . htmlToMarkdown ( 'google.com' ) ) . toBe ( 'google.com' ) ;
45+ } ) ;
46+
47+ test ( 'returns an empty string for an empty input' , ( ) => {
48+ expect ( Parser . htmlToMarkdown ( '' ) ) . toBe ( '' ) ;
49+ } ) ;
50+ } ) ;
2751} ) ;
You can’t perform that action at this time.
0 commit comments