-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathtest.js
More file actions
52 lines (41 loc) · 1.52 KB
/
test.js
File metadata and controls
52 lines (41 loc) · 1.52 KB
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
import test from 'ava';
import Yoga from '.';
test('yoga', t => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setWidth(100);
root.setHeight(100);
const firstChild = Yoga.Node.create(config);
firstChild.setFlexGrow(1);
firstChild.setFlexBasis(50);
root.insertChild(firstChild, 0);
const secondChild = Yoga.Node.create(config);
secondChild.setFlexGrow(1);
root.insertChild(secondChild, 1);
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
t.is(root.getComputedLeft(), 0);
t.is(root.getComputedTop(), 0);
t.is(root.getComputedWidth(), 100);
t.is(root.getComputedHeight(), 100);
t.is(firstChild.getComputedLeft(), 0);
t.is(firstChild.getComputedTop(), 0);
t.is(firstChild.getComputedWidth(), 100);
t.is(firstChild.getComputedHeight(), 75);
t.is(secondChild.getComputedLeft(), 0);
t.is(secondChild.getComputedTop(), 75);
t.is(secondChild.getComputedWidth(), 100);
t.is(secondChild.getComputedHeight(), 25);
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
t.is(root.getComputedLeft(), 0);
t.is(root.getComputedTop(), 0);
t.is(root.getComputedWidth(), 100);
t.is(root.getComputedHeight(), 100);
t.is(firstChild.getComputedLeft(), 0);
t.is(firstChild.getComputedTop(), 0);
t.is(firstChild.getComputedWidth(), 100);
t.is(firstChild.getComputedHeight(), 75);
t.is(secondChild.getComputedLeft(), 0);
t.is(secondChild.getComputedTop(), 75);
t.is(secondChild.getComputedWidth(), 100);
t.is(secondChild.getComputedHeight(), 25);
});