Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tree: Add tests for parent-position and direction #445

Merged
merged 2 commits into from
Jan 10, 2024
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
packages: imagemagick cargo parallel
version: 1.0
- name: Install typos-cli from crates.io
uses: baptiste0928/cargo-install@v2
uses: baptiste0928/cargo-install@v2.2.0
with:
crate: typos-cli
- name: Install just from crates.io
uses: baptiste0928/cargo-install@v2
uses: baptiste0928/cargo-install@v2.2.0
with:
crate: just
- uses: yusancky/setup-typst@v2
Expand Down
Binary file modified tests/tree/ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 20 additions & 3 deletions tests/tree/test.typ
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#set page(width: auto, height: auto)
#import "../../src/lib.typ": *
#import "/src/lib.typ": *
#import "/tests/helper.typ": *

#let data = (
[A], ([B], [C], [D]), ([E], [F])
)

#box(stroke: 2pt + red, canvas({
#test-case({
import draw: *
import tree: *

Expand All @@ -26,4 +27,20 @@
// Draw a "custom" connection between two nodes
let (a, b) = ("tree.0-0-1", "tree.0-1-0",)
line((a: a, number: .6, abs: true, b: b), (a: b, number: .6, abs: true, b: a), mark: (end: ">", start: ">"))
}))
})

#for position in ("begin", "center", "end") {
test-case({
cetz.draw.set-style(content: (frame: "rect", padding: .1))
cetz.tree.tree(data, parent-position: position)
})
h(.1cm)
}

#for direction in ("down", "up", "left", "right") {
test-case({
cetz.draw.set-style(content: (frame: "rect", padding: .1))
cetz.tree.tree(data, direction: direction)
})
h(.1cm)
}
Loading