Skip to content

Commit

Permalink
fix: ensure fit parameter will respect overriding value, fixes #268 (
Browse files Browse the repository at this point in the history
  • Loading branch information
sherwinski authored Mar 13, 2019
1 parent 6ef82e9 commit 15b0073
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"author": "Frederick Fogerty <[email protected]> (https://github.com/frederickfogerty)",
"contributors": [
"Frederick Fogerty <[email protected]> (https://github.com/frederickfogerty)",
"Max Kolyanov (https://github.com/maxkolyanov)"
"Max Kolyanov (https://github.com/maxkolyanov)",
"Sherwin Heydarbeygi <[email protected]> (https://github.com/sherwinski)"
],
"license": "ISC",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion src/react-imgix-bg.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ const BackgroundImpl = props => {

const renderedSrc = (() => {
const srcOptions = {
fit: "crop",
...imgixParams,
...(disableLibraryParam ? {} : { ixlib: `react-${PACKAGE_VERSION}` }),
width,
height,
fit: "crop",
dpr
};

Expand Down
24 changes: 24 additions & 0 deletions test/integration/react-imgix.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,30 @@ describe("Background Mode", () => {
expect(ref instanceof HTMLElement).toBe(true);
expect(findURIfromSUT(sut).getQueryParamValue("w")).toBe("100");
});
it("the fit parameter defaults to 'crop'", async () => {
const sut = await renderBGAndWaitUntilLoaded(
<div>
<Background src={src} className="bg-img">
<div>Content</div>
</Background>
</div>
);

const bgImageSrcURL = findURIfromSUT(sut);
expect(bgImageSrcURL.getQueryParamValue("fit")).toBe("crop");
});
it("the fit parameter can be overriden", async () => {
const sut = await renderBGAndWaitUntilLoaded(
<div>
<Background src={src} className="bg-img" imgixParams={{ fit: "clip" }}>
<div>Content</div>
</Background>
</div>
);

const bgImageSrcURL = findURIfromSUT(sut);
expect(bgImageSrcURL.getQueryParamValue("fit")).toBe("clip");
});
});

function injectScript(src) {
Expand Down

0 comments on commit 15b0073

Please sign in to comment.