From 0be9f8a0971a50f90181bf04935ba0b3f9607fca Mon Sep 17 00:00:00 2001 From: yohamta Date: Sat, 26 Nov 2022 12:26:26 +0900 Subject: [PATCH] add tests --- flex_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/flex_test.go b/flex_test.go index 3ab22a1..92fa24c 100644 --- a/flex_test.go +++ b/flex_test.go @@ -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