Skip to content

Commit

Permalink
fix: updates background component to merge props
Browse files Browse the repository at this point in the history
  • Loading branch information
longevitytina committed Dec 5, 2023
1 parent d6af82d commit 048b4fd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/react-imgix-bg.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ class BackgroundImpl extends React.Component {
: "cover",
};

// Focus here
return (
<div {...commonProps} className={className} ref={onRef} style={style}>
{children}
Expand Down
33 changes: 24 additions & 9 deletions test/unit/imgix-provider.test.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mount, shallow } from "enzyme";
import React from "react";
import ReactImgix, { ImgixProvider } from "../../src/index";
import ReactImgix, { ImgixProvider, Background } from "../../src/index";

const providerProps = {
domain: "sdk-test.imgix.net",
Expand All @@ -17,15 +17,22 @@ describe("ImgixProvider", () => {
const wrappedComponent = (
<ImgixProvider>
<ReactImgix {...imageProps} />
<Background {...imageProps} />
</ImgixProvider>
);

const expectedProps = {
children: (
<ReactImgix
src="https://assets.imgix.net/examples/pione.jpg"
sizes="50vw"
/>
<>
<ReactImgix
src="https://assets.imgix.net/examples/pione.jpg"
sizes="50vw"
/>
<Background
src="https://assets.imgix.net/examples/pione.jpg"
sizes="50vw"
/>
</>
),
value: {},
};
Expand All @@ -38,16 +45,23 @@ describe("ImgixProvider", () => {
const wrappedComponent = (
<ImgixProvider {...providerProps}>
<ReactImgix {...imageProps} />
<Background {...imageProps} />
</ImgixProvider>
);

// ensure Provider value correctly set
const expectedProps = {
children: (
<ReactImgix
src="https://assets.imgix.net/examples/pione.jpg"
sizes="50vw"
/>
<>
<ReactImgix
src="https://assets.imgix.net/examples/pione.jpg"
sizes="50vw"
/>
<Background
src="https://assets.imgix.net/examples/pione.jpg"
sizes="50vw"
/>
</>
),
value: { domain: "sdk-test.imgix.net", sizes: "100vw" },
};
Expand All @@ -66,6 +80,7 @@ describe("ImgixProvider", () => {
const wrappedComponent = (
<ImgixProvider {...providerProps}>
<ReactImgix {...modifiedProps} />
<Background {...modifiedProps} />
</ImgixProvider>
);

Expand Down

0 comments on commit 048b4fd

Please sign in to comment.