Skip to content

Commit

Permalink
Add review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonieaj committed Jun 30, 2024
1 parent 33175bc commit 28adf50
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 5 additions & 4 deletions memory-viz/src/automate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ function drawAutomated(objects: DrawnEntity[], width, configuration) {
min_width += requiredWidth + 2 * configuration.padding + 1;

if (width < min_width) {
console.log(
`WARNING: provided width (${width}) is smaller than the minimum width` +
` of the canvas (${min_width}). The provided width has been overwritten` +
console.warn(
`WARNING: provided width (${width}) is smaller than the required width` +
` (${min_width}). The provided width has been overwritten` +
` in the generated diagram.`
);
width = min_width;
Expand Down Expand Up @@ -119,7 +119,7 @@ function drawAutomatedStackFrames(stack_frames: DrawnEntity[], configuration) {
min_required_height = height + min_required_height;
}

required_width += configuration.left_margin;
required_width += configuration.padding;

return {
StackFrames: draw_stack_frames,
Expand Down Expand Up @@ -209,6 +209,7 @@ function drawAutomatedOtherItems(
let curr_row_objects = [];
for (const item of objs) {
let hor_reach = x_coord + item.width + PADDING;

if (hor_reach < max_width) {
item.x = x_coord;
item.y = y_coord;
Expand Down
10 changes: 9 additions & 1 deletion memory-viz/src/tests/draw.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -775,12 +775,20 @@ describe("draw function", () => {
style: ["highlight"],
},
];
const spy = jest.spyOn(global.console, "log");
const spy = jest.spyOn(global.console, "warn");
draw(objects, true, {
width: 13,
roughjs_config: { options: { seed: 12345 } },
});
expect(spy).toHaveBeenCalledTimes(1);
console.log(spy.mock.calls[0][0]);

const message = new RegExp(
"^WARNING: provided width \\(\\d+\\) is smaller than " +
"the required width \\(\\d+\\). The provided width has been overwritten " +
"in the generated diagram.$"
);
expect(message.test(spy.mock.calls[0][0])).toBe(true);
spy.mockRestore();
});

Expand Down

0 comments on commit 28adf50

Please sign in to comment.