Skip to content

Commit

Permalink
tests: provide regression against #276, custom renderer wrapper prop …
Browse files Browse the repository at this point in the history
…ignored
  • Loading branch information
jsamr committed Jul 21, 2020
1 parent 343a83e commit a228437
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/__tests__/regression.276.cusom-renderer-wrapper.test.js
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");
});
});
});

0 comments on commit a228437

Please sign in to comment.