-
-
Notifications
You must be signed in to change notification settings - Fork 588
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 #141, blur images on iOS
- Loading branch information
Showing
1 changed file
with
15 additions
and
11 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,19 +1,23 @@ | ||
import React from "react"; | ||
import { Image } from "react-native"; | ||
import { render } from "react-native-testing-library"; | ||
import HTMLImage from "../HTMLImage"; | ||
|
||
function getSize(source, callback) { | ||
setTimeout(() => callback(640, 360), 1) | ||
} | ||
|
||
Image.getSize = getSize.bind(Image); | ||
|
||
/** | ||
* https://github.com/archriss/react-native-render-html/issues/141 | ||
*/ | ||
describe("HTMLImage component should pass regression test #141", () => { | ||
it("doesn't display the image prior to receiving original dimensions", () => { | ||
const {} = render(<HTMLImage source={{ uri: "http://via.placeholder.com/640x360" }} />); | ||
}) | ||
}); | ||
it("doesn't display the image prior to receiving original dimensions", async () => { | ||
const source = { uri: "http://via.placeholder.com/640x360" }; | ||
const style = {}; | ||
const { findByTestId, getByTestId, queryByTestId } = render( | ||
<HTMLImage key="1" style={style} source={source} /> | ||
); | ||
const placeholder = getByTestId("image-placeholder"); | ||
expect(placeholder).toBeTruthy(); | ||
const imageLayout = queryByTestId("image-layout") | ||
expect(imageLayout).toBeFalsy(); | ||
await expect( | ||
findByTestId("image-layout", { timeout: 10 }) | ||
).resolves.toBeTruthy(); | ||
}); | ||
}); |