Skip to content

Commit

Permalink
tests: implement regression tests for issues #343 and #377
Browse files Browse the repository at this point in the history
  • Loading branch information
jsamr committed Jul 15, 2020
1 parent c900bcb commit 78c680c
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/__tests__/regression.classes-styles-re-render.377.test.js
@@ -0,0 +1,38 @@
import React from "react";
import { Text, StyleSheet } from "react-native";
import HTML from "../index";
import Renderer from "react-test-renderer";

/**
* https://github.com/archriss/react-native-render-html/issues/377
*/
describe("HTML component", () => {
const colorYellow = {
color: "yellow",
};
const colorGreen = {
color: "green",
};
const tagsStylesInstance1 = {
highlight: colorYellow,
};
const tagsStylesInstance2 = {
highlight: colorGreen,
};
it("should pass regression #343 regarding classesStyles prop", () => {
const testRenderer = Renderer.create(
<HTML
html={'<p class="highlight">hello world</p>'}
classesStyles={tagsStylesInstance1}
/>
);
testRenderer.update(
<HTML
html={'<p class="highlight">hello world</p>'}
classesStyles={tagsStylesInstance2}
/>
);
const text = testRenderer.root.findByType(Text);
expect(StyleSheet.flatten(text.props.style)).toMatchObject(colorGreen);
});
});
32 changes: 32 additions & 0 deletions src/__tests__/regression.tags-styles-re-render.343.test.js
@@ -0,0 +1,32 @@
import React from "react";
import { Text, StyleSheet } from "react-native";
import HTML from "../index";
import Renderer from "react-test-renderer";

/**
* https://github.com/archriss/react-native-render-html/issues/343
*/
describe("HTML component", () => {
const letterSpacing2 = {
letterSpacing: 2,
};
const letterSpacing3 = {
letterSpacing: 3
};
const tagsStylesInstance1 = {
a: letterSpacing2,
};
const tagsStylesInstance2 = {
a: letterSpacing3,
};
it("should pass regression #343 regarding tagsStyles prop", () => {
const testRenderer = Renderer.create(
<HTML html={"<a>hello world</a>"} tagsStyles={tagsStylesInstance1} />
);
testRenderer.update(
<HTML html={"<a>hello world</a>"} tagsStyles={tagsStylesInstance2} />
);
const text = testRenderer.root.findByType(Text);
expect(StyleSheet.flatten(text.props.style)).toMatchObject(letterSpacing3);
});
});

0 comments on commit 78c680c

Please sign in to comment.