Skip to content

Commit

Permalink
tree: Add tests for parent-position and direction (#445)
Browse files Browse the repository at this point in the history
Adds the missing tests for #444.
  • Loading branch information
johannes-wolf authored Jan 10, 2024
1 parent 9027bae commit b1cbb7a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
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)
}

0 comments on commit b1cbb7a

Please sign in to comment.