From b0e65e852471b9fa65385e5b39f05d8308331ca6 Mon Sep 17 00:00:00 2001 From: "Jules Sam. Randolph" Date: Sat, 18 Jul 2020 14:36:34 -0300 Subject: [PATCH] tests: provide regression against #276, custom renderer wrapper prop ignored --- ...ression.276.cusom-renderer-wrapper.test.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/__tests__/regression.276.cusom-renderer-wrapper.test.js diff --git a/src/__tests__/regression.276.cusom-renderer-wrapper.test.js b/src/__tests__/regression.276.cusom-renderer-wrapper.test.js new file mode 100644 index 000000000..fba09b928 --- /dev/null +++ b/src/__tests__/regression.276.cusom-renderer-wrapper.test.js @@ -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 }) => ( + + {children} + + ); + const customRenderers = { + span: { + renderer: (_styles, children, _attrs, { key }) => ( + {children} + ), + wrapper: "View", + }, + }; + const { UNSAFE_getByType } = render( + foohello world

"} + renderers={customRenderers} + /> + ); + const span = UNSAFE_getByType(Span); + expect(span.parent.type).toBe("View"); + }); + }); +});