Skip to content

Commit

Permalink
add back the check for --output in some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leowrites committed Sep 13, 2024
1 parent 1d30a19 commit d18e457
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion memory-viz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"Mimis Chlympatsos",
"Yoonie Jang",
"Shannon Komguem",
"Utku Egemen Umut",
"Siqi (Leo) Liu",
"Utku Egemen Umut",
"Sarah Wang",
"Ziyuan (Jerry) Zhang"
],
Expand Down
16 changes: 14 additions & 2 deletions memory-viz/src/tests/cli.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ const input = JSON.stringify(
null
);

// Helper function for determining the output path of the SVG
const getSVGPath = (isOutputOption: boolean) => {
if (isOutputOption) {
return outputPath;
}
const directoryPath = process.cwd();
const fileName = path.basename(filePath.replace(".json", ".svg"));

return path.resolve(directoryPath, fileName);
};

describe.each([
{
inputs: "filepath and output",
Expand Down Expand Up @@ -49,9 +60,10 @@ describe.each([
exec(`memory-viz ${command}`, (err) => {
if (err) throw err;

const fileContent = fs.readFileSync(outputPath, "utf8");
const svgFilePath = getSVGPath(command.includes("--output"));
const fileContent = fs.readFileSync(svgFilePath, "utf8");
expect(fileContent).toMatchSnapshot();
fs.unlinkSync(outputPath);
fs.unlinkSync(svgFilePath);

done();
});
Expand Down

0 comments on commit d18e457

Please sign in to comment.