Files
iNaturalistReactNative/tests/unit/components/UserText/buildUserTextHtml.test.js
Johannes Klein 2efb99fb74 Switch to @native-html/render to support markdown again (#3553)
* Update package.json

Without the babel plugin the app does not start because of an error with the new package.

* Update babel.config.js

* Update package-lock.json

* Switch to new package for Wikipedia text

* Update Podfile.lock

* Use new package in UserText

* Link underline was blue, now green again

* Make headings in user text the same as in the app

* Fix typo?

Not hundred percent sure about this, but MDN docs show no t tag and the original list in inaturalist has tfoot in this place here.

* Remove tag that is not supported on web

* Refactor making of html into helper function

* Update index.ts

* Create a snapshot test for build html function
2026-04-21 22:03:34 +02:00

53 lines
1.1 KiB
JavaScript

/* eslint-disable no-useless-escape */
import { buildUserTextHtml } from "components/SharedComponents/UserText";
// Frozen copy of userText fixture.
// Update fixture + snapshot if expanding coverage.
const TEST_USER_TEXT_FIXTURE = `
**bold**
[An observation with id](https://staging.inaturalist.org/observations/350544545)
*italics*
> blockquote
[A project with id](https://staging.inaturalist.org/projects/3545)
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6
---
* unordered list
* second item
Normal text before
<p>Paragraph</p>
Normal text after
1. Ordered list
1. Second item
|table|up|top!|
|-|-|-|
|foo|bar|baz|
Choice lines of fine words
Separated by line breaks
Should look just fine, k?
1\. An escaped
13\. List
33\. is possible
<abbr title="Abbreviation abbreviation">HTML</abbr> is still <del>possible</del><ins>probable</ins>!
`;
describe( "building HTML for userText fixture", () => {
it( "matches HTML snapshot", () => {
expect( buildUserTextHtml( TEST_USER_TEXT_FIXTURE ) ).toMatchSnapshot( );
} );
} );