Skip to content

Commit

Permalink
test: add counter-regression test for #524
Browse files Browse the repository at this point in the history
  • Loading branch information
jsamr committed Nov 25, 2021
1 parent 7bd5045 commit 978cc2a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import RenderHTML from '../RenderHTML';
import { render } from '@testing-library/react-native';

/**
* https://github.com/meliorence/react-native-render-html/issues/524
**/
describe('RenderHTML component', () => {
describe('should pass regression regarding percent width', () => {
it('dimensions should not be derived from aspect ratio', async () => {
const renderersProps = {
img: {
enableExperimentalPercentWidth: true
}
};
const { findByTestId } = render(
<RenderHTML
debug={false}
contentWidth={300}
renderersProps={renderersProps}
source={{
html: '<img style="width:100%" src="https://img.com/1920x1080" width="800" height="400"/>'
}}
/>
);
const img = await findByTestId('image-success');
expect(img).toHaveStyle({
width: 300,
height: 400
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,11 @@ describe('IMGElement', () => {
const image = await findByTestId('image-success');
expect(image).toBeTruthy();
expect(image).toHaveStyle({
width: 640
width: 640,
height: 360
});
});
it('should support strings for width and height which can be parsed to floats', async () => {
it('should support strings for width and height which can be parsed to numbers', async () => {
const source = { uri: 'http://via.placeholder.com/640x360' };
const style = {
width: '50'
Expand All @@ -340,7 +341,7 @@ describe('IMGElement', () => {
const { findByTestId } = render(
<HTMLImgElement
enableExperimentalPercentWidth
contentWidth={250}
contentWidth={contentWidth}
{...style}
source={source}
/>
Expand Down

0 comments on commit 978cc2a

Please sign in to comment.