-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdefault_values_test.go
112 lines (90 loc) · 4.54 KB
/
default_values_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package flex
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestAssert_default_values(t *testing.T) {
root := NewNode()
assert.Equal(t, 0, len(root.Children))
var nilNode *Node
assert.Equal(t, nilNode, root.GetChild(1))
assert.Equal(t, nilNode, root.GetChild(0))
assert.Equal(t, DirectionInherit, root.Style.Direction)
assert.Equal(t, FlexDirectionColumn, root.Style.FlexDirection)
assert.Equal(t, JustifyFlexStart, root.Style.JustifyContent)
assert.Equal(t, AlignFlexStart, root.Style.AlignContent)
assert.Equal(t, AlignStretch, root.Style.AlignItems)
assert.Equal(t, AlignAuto, root.Style.AlignSelf)
assert.Equal(t, PositionTypeRelative, root.Style.PositionType)
assert.Equal(t, WrapNoWrap, root.Style.FlexWrap)
assert.Equal(t, OverflowVisible, root.Style.Overflow)
assertFloatEqual(t, 0, root.StyleGetFlexGrow())
assertFloatEqual(t, 0, root.StyleGetFlexShrink())
assert.Equal(t, root.Style.FlexBasis.Unit, UnitAuto)
assert.Equal(t, root.StyleGetPosition(EdgeLeft).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetPosition(EdgeTop).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetPosition(EdgeRight).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetPosition(EdgeBottom).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetPosition(EdgeStart).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetPosition(EdgeEnd).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetMargin(EdgeLeft).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetMargin(EdgeTop).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetMargin(EdgeRight).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetMargin(EdgeBottom).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetMargin(EdgeStart).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetMargin(EdgeEnd).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetPadding(EdgeLeft).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetPadding(EdgeTop).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetPadding(EdgeRight).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetPadding(EdgeBottom).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetPadding(EdgeStart).Unit, UnitUndefined)
assert.Equal(t, root.StyleGetPadding(EdgeEnd).Unit, UnitUndefined)
assert.True(t, FloatIsUndefined(root.StyleGetBorder(EdgeLeft)))
assert.True(t, FloatIsUndefined(root.StyleGetBorder(EdgeTop)))
assert.True(t, FloatIsUndefined(root.StyleGetBorder(EdgeRight)))
assert.True(t, FloatIsUndefined(root.StyleGetBorder(EdgeBottom)))
assert.True(t, FloatIsUndefined(root.StyleGetBorder(EdgeStart)))
assert.True(t, FloatIsUndefined(root.StyleGetBorder(EdgeEnd)))
assert.Equal(t, root.StyleGetWidth().Unit, UnitAuto)
assert.Equal(t, root.StyleGetHeight().Unit, UnitAuto)
assert.Equal(t, root.StyleGetMinWidth().Unit, UnitUndefined)
assert.Equal(t, root.StyleGetMinHeight().Unit, UnitUndefined)
assert.Equal(t, root.StyleGetMaxWidth().Unit, UnitUndefined)
assert.Equal(t, root.StyleGetMaxHeight().Unit, UnitUndefined)
assertFloatEqual(t, 0, root.LayoutGetLeft())
assertFloatEqual(t, 0, root.LayoutGetTop())
assertFloatEqual(t, 0, root.LayoutGetRight())
assertFloatEqual(t, 0, root.LayoutGetBottom())
assertFloatEqual(t, 0, root.LayoutGetMargin(EdgeLeft))
assertFloatEqual(t, 0, root.LayoutGetMargin(EdgeTop))
assertFloatEqual(t, 0, root.LayoutGetMargin(EdgeRight))
assertFloatEqual(t, 0, root.LayoutGetMargin(EdgeBottom))
assertFloatEqual(t, 0, root.LayoutGetPadding(EdgeLeft))
assertFloatEqual(t, 0, root.LayoutGetPadding(EdgeTop))
assertFloatEqual(t, 0, root.LayoutGetPadding(EdgeRight))
assertFloatEqual(t, 0, root.LayoutGetPadding(EdgeBottom))
assertFloatEqual(t, 0, root.LayoutGetBorder(EdgeLeft))
assertFloatEqual(t, 0, root.LayoutGetBorder(EdgeTop))
assertFloatEqual(t, 0, root.LayoutGetBorder(EdgeRight))
assertFloatEqual(t, 0, root.LayoutGetBorder(EdgeBottom))
assert.True(t, FloatIsUndefined(root.LayoutGetWidth()))
assert.True(t, FloatIsUndefined(root.LayoutGetHeight()))
assert.Equal(t, DirectionInherit, root.Layout.Direction)
}
func TestAssert_webdefault_values(t *testing.T) {
config := NewConfig()
config.UseWebDefaults = true
root := NewNodeWithConfig(config)
assert.Equal(t, FlexDirectionRow, root.Style.FlexDirection)
assert.Equal(t, AlignStretch, root.Style.AlignContent)
assertFloatEqual(t, 1, root.StyleGetFlexShrink())
}
func TestAssert_webdefault_values_reset(t *testing.T) {
config := NewConfig()
config.UseWebDefaults = true
root := NewNodeWithConfig(config)
root.Reset()
assert.Equal(t, FlexDirectionRow, root.Style.FlexDirection)
assert.Equal(t, AlignStretch, root.Style.AlignContent)
assertFloatEqual(t, 1, root.StyleGetFlexShrink())
}