Skip to content

Commit

Permalink
Update drawPrimitive to remove quotation marks from non-str objects (#45
Browse files Browse the repository at this point in the history
)
  • Loading branch information
yoonieaj authored Jun 19, 2024
1 parent da9c3d5 commit d65c51a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Fixed a bug where box fill colours would cover box text, and changed the implementation of `hide` style option.
- Removed double quotes when rendering objects of type `None`.
- Removed double quotes when rendering objects that are not of type `str`.

### 📚 Documentation and demo website changes

Expand Down
6 changes: 3 additions & 3 deletions memory-viz/src/memory_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ export class MemoryModel {
let display_text;
if (type === "bool") {
display_text = value ? "True" : "False";
} else if (type === "None") {
display_text = "None";
} else {
} else if (type === "str") {
display_text = JSON.stringify(value);
} else {
display_text = String(value);
}

if (value !== null && value !== undefined) {
Expand Down
2 changes: 2 additions & 0 deletions memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions memory-viz/src/tests/draw.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -749,4 +749,20 @@ describe("draw function", () => {
const svg: String = m.serializeSVG();
expect(svg).toMatchSnapshot();
});

it("renders range object", () => {
const objects: Array<Object> = [
{
type: "range",
id: 42,
value: "range(1, 5)",
},
];
const m: InstanceType<typeof MemoryModel> = draw(objects, true, {
width: 1300,
roughjs_config: { options: { seed: 12345 } },
});
const svg: String = m.serializeSVG();
expect(svg).toMatchSnapshot();
});
});

0 comments on commit d65c51a

Please sign in to comment.