-
-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: provide regression against #276, custom renderer wrapper prop …
…ignored
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/__tests__/regression.276.cusom-renderer-wrapper.test.js
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from "react"; | ||
import { Text, View } from "react-native"; | ||
import HTML from "../index"; | ||
import { render } from "react-native-testing-library"; | ||
|
||
/** | ||
* /~https://github.com/archriss/react-native-render-html/issues/276 | ||
*/ | ||
describe("HTML component", () => { | ||
describe("should pass regression #276 regarding customRenderer prop", () => { | ||
it("when provided, should use View wrapper to render a tag which has been defined in customRenderers and which default wrapper is Text", () => { | ||
const Span = ({ children, ...props }) => ( | ||
<View {...props}> | ||
<Text>{children}</Text> | ||
</View> | ||
); | ||
const customRenderers = { | ||
span: { | ||
renderer: (_styles, children, _attrs, { key }) => ( | ||
<Span key={key}>{children}</Span> | ||
), | ||
wrapper: "View", | ||
}, | ||
}; | ||
const { UNSAFE_getByType } = render( | ||
<HTML | ||
html={"<p>foo<span>hello world</span></p>"} | ||
renderers={customRenderers} | ||
/> | ||
); | ||
const span = UNSAFE_getByType(Span); | ||
expect(span.parent.type).toBe("View"); | ||
}); | ||
}); | ||
}); |