Skip to content

Commit

Permalink
Merge pull request #27 from yohamta/add-tests
Browse files Browse the repository at this point in the history
add tests
  • Loading branch information
yohamta authored Nov 26, 2022
2 parents 92e9b0c + 0be9f8a commit 48bccd1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions flex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,39 @@ func TestNestedChildGrow(t *testing.T) {
assert.Equal(t, image.Rect(0, 0, 1000, 1000), mock.Frame)
}

func TestMerginWithChild(t *testing.T) {
flex := &View{
Width: 1000,
Height: 1000,
Direction: Column,
AlignItems: AlignItemEnd,
Justify: JustifyEnd,
}

mock := mockHandler{}

flex.AddChild(
(&View{
MarginRight: 50,
MarginBottom: 100,
Direction: Column,
AlignItems: AlignItemEnd,
Justify: JustifyEnd,
}).AddChild(
&View{
Width: 100,
Height: 100,
Handler: &mock,
},
),
)

flex.Update()
flex.Draw(nil)

assert.Equal(t, image.Rect(850, 800, 950, 900), mock.Frame)
}

func flexItemBounds(parent *View, child *View) image.Rectangle {
mock := &mockHandler{}
child.Handler = mock
Expand Down

0 comments on commit 48bccd1

Please sign in to comment.