Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/post-images/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"hast-util-to-string": "^3.0.1",
"remark-parse": "^11.0.0",
"remark-rehype": "^11.1.2",
"satori": "0.13.2",
"satori": "0.25.0",
"sharp": "catalog:",
"typebox": "catalog:",
"unified": "^11.0.5",
Expand Down
Binary file added packages/post-images/tests/banner-long-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions packages/post-images/tests/banner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,47 @@ test("Should render the expected banner image", async () => {
});
expect(equal).toEqual(true);
});

// Regression coverage for #125: longer, multi-line code should still render
// in the blurred banner background rather than disappearing.
test("Should render long multi-line code in the banner background", async () => {
const post = await mockPostData();
post.code = `import { useState, useEffect } from "react";
import type { FC } from "react";

interface Props {
title: string;
onSave: (value: string) => void;
}

export const Editor: FC<Props> = ({ title, onSave }) => {
const [value, setValue] = useState("");

useEffect(() => {
console.log("mounted", title);
return () => console.log("unmounted");
}, [title]);

const handleSubmit = (event: React.FormEvent) => {
event.preventDefault();
onSave(value);
};

return (
<form onSubmit={handleSubmit}>
<input value={value} onChange={(e) => setValue(e.target.value)} />
<button type="submit">Save</button>
</form>
);
};`;

const buffer = await createPostImage(banner, post);

const snapshot = "./tests/banner-long-code.png";
// await (await import("fs/promises")).writeFile(snapshot, buffer);

const { equal } = await looksSame(snapshot, buffer, {
ignoreAntialiasing: true,
});
expect(equal).toEqual(true);
});
28 changes: 15 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.