@tamagui/react-native-web-lite
Version:
React Native for Web
50 lines (49 loc) • 1.46 kB
JavaScript
import { render } from "@testing-library/react";
import Text from "../../Text/index.mjs";
import ImageBackground from "../index.mjs";
import { jsx } from "react/jsx-runtime";
function findImage(container) {
return container.firstChild.firstChild;
}
describe("components/ImageBackground", () => {
describe('prop "children"', () => {
test("render child content", () => {
const {
getByText
} = render(/* @__PURE__ */jsx(ImageBackground, {
children: /* @__PURE__ */jsx(Text, {
children: "Hello World!"
})
}));
expect(getByText("Hello World!")).toBeDefined();
});
});
describe('prop "imageStyle"', () => {
test("sets the style of the underlying Image", () => {
const imageStyle = {
width: 40,
height: 60
};
const {
container
} = render(/* @__PURE__ */jsx(ImageBackground, {
imageStyle
}));
expect(findImage(container).getAttribute("style").includes("width: 40px; height: 60px;")).toBe(true);
});
});
describe('prop "style"', () => {
test("sets the style of the container View", () => {
const style = {
margin: 40
};
const {
container
} = render(/* @__PURE__ */jsx(ImageBackground, {
style
}));
expect(container.firstChild.getAttribute("style")).toEqual("margin: 40px 40px 40px 40px;");
});
});
});
//# sourceMappingURL=index-test.mjs.map