Files
zeekay 1c508dd3df publish the JavaScript package as @hanzo/layout 3.3.0
The package name is also the specifier every test and the playground import, so
it moves as one piece: package.json, the tsconfig path, the generator, and the
website workspace that depends on it. Generated tests are re-signed.

Dated blog posts keep the old name - they are a record of upstream's 2.0 and 3.0
releases, not instructions for this package.
2026-08-28 11:58:17 -07:00

3788 lines
140 KiB
TypeScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<9d851ed4d29ee1d7232f1977643b2ea6>>
* generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGGridTest.html
*/
import { intrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from '@hanzo/layout';
import {
Align,
BoxSizing,
Direction,
Display,
Edge,
Errata,
ExperimentalFeature,
FlexDirection,
GridTrackType,
Gutter,
Justify,
MeasureMode,
Overflow,
PositionType,
Unit,
Wrap,
} from '@hanzo/layout';
test('grid_all_properties', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridAutoRows = [];
rootGridAutoRows.push({type: GridTrackType.Points, value: 100});
rootGridAutoRows.push({type: GridTrackType.Points, value: 200});
root.setGridAutoRows(rootGridAutoRows);
const rootGridAutoColumns = [];
rootGridAutoColumns.push({type: GridTrackType.Points, value: 100});
rootGridAutoColumns.push({type: GridTrackType.Points, value: 200});
root.setGridAutoColumns(rootGridAutoColumns);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(100);
root_child0.setHeight(100);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(5);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(3);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(100);
root_child1.setHeight(100);
root_child1.setGridRowStart(2);
root_child1.setGridRowEnd(4);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(600);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(400);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(400);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(200);
expect(root_child2.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(600);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(500);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(200);
expect(root_child2.getComputedHeight()).toBe(100);
});
test('grid_auto_tracks', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
root.setWidth(220);
root.setHeight(160);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Auto});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setJustifyContent(Justify.Stretch);
const root_child0 = Yoga.Node.create(config);
root_child0.setHeight(50);
root_child0.setPadding(Edge.All, 10);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(220);
expect(root.getComputedHeight()).toBe(160);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(50);
expect(root_child1.getComputedLeft()).toBe(120);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(50);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(50);
expect(root_child2.getComputedWidth()).toBe(120);
expect(root_child2.getComputedHeight()).toBe(0);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(220);
expect(root.getComputedHeight()).toBe(160);
expect(root_child0.getComputedLeft()).toBe(100);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(50);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(50);
expect(root_child2.getComputedLeft()).toBe(100);
expect(root_child2.getComputedTop()).toBe(50);
expect(root_child2.getComputedWidth()).toBe(120);
expect(root_child2.getComputedHeight()).toBe(0);
});
test('grid_auto_tracks_with_gap', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Auto});
rootGridTemplateColumns.push({type: GridTrackType.Auto});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Auto});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setGap(Gutter.Column, 10);
root.setGap(Gutter.Row, 15);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(120);
root_child0.setHeight(40);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(120);
root_child1.setHeight(40);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPadding(Edge.All, 40);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(250);
expect(root.getComputedHeight()).toBe(135);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(40);
expect(root_child1.getComputedLeft()).toBe(130);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(40);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(55);
expect(root_child2.getComputedWidth()).toBe(120);
expect(root_child2.getComputedHeight()).toBe(80);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(250);
expect(root.getComputedHeight()).toBe(135);
expect(root_child0.getComputedLeft()).toBe(130);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(40);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(40);
expect(root_child2.getComputedLeft()).toBe(130);
expect(root_child2.getComputedTop()).toBe(55);
expect(root_child2.getComputedWidth()).toBe(120);
expect(root_child2.getComputedHeight()).toBe(80);
});
test('grid_auto_tracks_with_margins', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Auto});
rootGridTemplateColumns.push({type: GridTrackType.Auto});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
root.setGridTemplateRows(rootGridTemplateRows);
root.setGap(Gutter.Column, 10);
root.setGap(Gutter.Row, 15);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(120);
root_child0.setHeight(40);
root_child0.setMargin(Edge.Top, 10);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(120);
root_child1.setHeight(40);
root_child1.setMargin(Edge.Top, 10);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPadding(Edge.All, 40);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(250);
expect(root.getComputedHeight()).toBe(415);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(10);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(40);
expect(root_child1.getComputedLeft()).toBe(130);
expect(root_child1.getComputedTop()).toBe(10);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(40);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(215);
expect(root_child2.getComputedWidth()).toBe(120);
expect(root_child2.getComputedHeight()).toBe(200);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(250);
expect(root.getComputedHeight()).toBe(415);
expect(root_child0.getComputedLeft()).toBe(130);
expect(root_child0.getComputedTop()).toBe(10);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(40);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(10);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(40);
expect(root_child2.getComputedLeft()).toBe(130);
expect(root_child2.getComputedTop()).toBe(215);
expect(root_child2.getComputedWidth()).toBe(120);
expect(root_child2.getComputedHeight()).toBe(200);
});
test('grid_spanning_items', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Auto});
rootGridTemplateColumns.push({type: GridTrackType.Auto});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setGap(Gutter.All, 10);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(6);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(3);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPadding(Edge.All, 40);
root_child1.setGridColumnStart(1);
root_child1.setGridColumnEnd(3);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(100);
root_child2.setHeight(100);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(210);
expect(root.getComputedHeight()).toBe(320);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(210);
expect(root_child0.getComputedHeight()).toBe(210);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(220);
expect(root_child1.getComputedWidth()).toBe(80);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(90);
expect(root_child2.getComputedTop()).toBe(220);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(210);
expect(root.getComputedHeight()).toBe(320);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(210);
expect(root_child0.getComputedHeight()).toBe(210);
expect(root_child1.getComputedLeft()).toBe(130);
expect(root_child1.getComputedTop()).toBe(220);
expect(root_child1.getComputedWidth()).toBe(80);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(20);
expect(root_child2.getComputedTop()).toBe(220);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(100);
});
test('grid_holy_grail', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 80});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 60});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(500);
root.setHeight(400);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(4);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth("100%");
root_child0.setHeight(80);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(1);
root_child1.setGridColumnEnd(2);
root_child1.setGridRowStart(2);
root_child1.setGridRowEnd(3);
root_child1.setWidth(200);
root_child1.setHeight("100%");
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(2);
root_child2.setGridColumnEnd(3);
root_child2.setGridRowStart(2);
root_child2.setGridRowEnd(3);
root_child2.setWidth("100%");
root_child2.setHeight("100%");
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(3);
root_child3.setGridColumnEnd(4);
root_child3.setGridRowStart(2);
root_child3.setGridRowEnd(3);
root_child3.setWidth(200);
root_child3.setHeight("100%");
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setGridColumnStart(1);
root_child4.setGridColumnEnd(4);
root_child4.setGridRowStart(3);
root_child4.setGridRowEnd(4);
root_child4.setWidth("100%");
root_child4.setHeight(60);
root.insertChild(root_child4, 4);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(500);
expect(root.getComputedHeight()).toBe(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(500);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(80);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(260);
expect(root_child2.getComputedLeft()).toBe(200);
expect(root_child2.getComputedTop()).toBe(80);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(260);
expect(root_child3.getComputedLeft()).toBe(300);
expect(root_child3.getComputedTop()).toBe(80);
expect(root_child3.getComputedWidth()).toBe(200);
expect(root_child3.getComputedHeight()).toBe(260);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(340);
expect(root_child4.getComputedWidth()).toBe(500);
expect(root_child4.getComputedHeight()).toBe(60);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(500);
expect(root.getComputedHeight()).toBe(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(500);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(300);
expect(root_child1.getComputedTop()).toBe(80);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(260);
expect(root_child2.getComputedLeft()).toBe(200);
expect(root_child2.getComputedTop()).toBe(80);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(260);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(80);
expect(root_child3.getComputedWidth()).toBe(200);
expect(root_child3.getComputedHeight()).toBe(260);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(340);
expect(root_child4.getComputedWidth()).toBe(500);
expect(root_child4.getComputedHeight()).toBe(60);
});
test('grid_sidebar_layout', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 250});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
root.setHeight(500);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth(250);
root_child0.setHeight("100%");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(2);
root_child1.setGridColumnEnd(3);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(2);
root_child1.setWidth("100%");
root_child1.setHeight("100%");
root.insertChild(root_child1, 1);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(500);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(250);
expect(root_child0.getComputedHeight()).toBe(500);
expect(root_child1.getComputedLeft()).toBe(250);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(500);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(500);
expect(root_child0.getComputedLeft()).toBe(150);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(250);
expect(root_child0.getComputedHeight()).toBe(500);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(500);
});
test('grid_header_content_footer', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 80});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
root.setHeight(600);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth("100%");
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(1);
root_child1.setGridColumnEnd(2);
root_child1.setGridRowStart(2);
root_child1.setGridRowEnd(3);
root_child1.setWidth("100%");
root_child1.setHeight("100%");
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(1);
root_child2.setGridColumnEnd(2);
root_child2.setGridRowStart(3);
root_child2.setGridRowEnd(4);
root_child2.setWidth("100%");
root_child2.setHeight(80);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(600);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(400);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(400);
expect(root_child1.getComputedHeight()).toBe(420);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(520);
expect(root_child2.getComputedWidth()).toBe(400);
expect(root_child2.getComputedHeight()).toBe(80);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(600);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(400);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(400);
expect(root_child1.getComputedHeight()).toBe(420);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(520);
expect(root_child2.getComputedWidth()).toBe(400);
expect(root_child2.getComputedHeight()).toBe(80);
});
test('grid_card_layout', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 250});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 250});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(600);
root.setHeight(500);
root.setGap(Gutter.All, 20);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth(200);
root_child0.setHeight(250);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(2);
root_child1.setGridColumnEnd(3);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(2);
root_child1.setWidth(200);
root_child1.setHeight(250);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(3);
root_child2.setGridColumnEnd(4);
root_child2.setGridRowStart(1);
root_child2.setGridRowEnd(2);
root_child2.setWidth(200);
root_child2.setHeight(250);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(1);
root_child3.setGridColumnEnd(2);
root_child3.setGridRowStart(2);
root_child3.setGridRowEnd(3);
root_child3.setWidth(200);
root_child3.setHeight(250);
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setGridColumnStart(2);
root_child4.setGridColumnEnd(3);
root_child4.setGridRowStart(2);
root_child4.setGridRowEnd(3);
root_child4.setWidth(200);
root_child4.setHeight(250);
root.insertChild(root_child4, 4);
const root_child5 = Yoga.Node.create(config);
root_child5.setGridColumnStart(3);
root_child5.setGridColumnEnd(4);
root_child5.setGridRowStart(2);
root_child5.setGridRowEnd(3);
root_child5.setWidth(200);
root_child5.setHeight(250);
root.insertChild(root_child5, 5);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(600);
expect(root.getComputedHeight()).toBe(500);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(250);
expect(root_child1.getComputedLeft()).toBe(220);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(250);
expect(root_child2.getComputedLeft()).toBe(440);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(200);
expect(root_child2.getComputedHeight()).toBe(250);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(270);
expect(root_child3.getComputedWidth()).toBe(200);
expect(root_child3.getComputedHeight()).toBe(250);
expect(root_child4.getComputedLeft()).toBe(220);
expect(root_child4.getComputedTop()).toBe(270);
expect(root_child4.getComputedWidth()).toBe(200);
expect(root_child4.getComputedHeight()).toBe(250);
expect(root_child5.getComputedLeft()).toBe(440);
expect(root_child5.getComputedTop()).toBe(270);
expect(root_child5.getComputedWidth()).toBe(200);
expect(root_child5.getComputedHeight()).toBe(250);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(600);
expect(root.getComputedHeight()).toBe(500);
expect(root_child0.getComputedLeft()).toBe(400);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(250);
expect(root_child1.getComputedLeft()).toBe(180);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(250);
expect(root_child2.getComputedLeft()).toBe(-40);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(200);
expect(root_child2.getComputedHeight()).toBe(250);
expect(root_child3.getComputedLeft()).toBe(400);
expect(root_child3.getComputedTop()).toBe(270);
expect(root_child3.getComputedWidth()).toBe(200);
expect(root_child3.getComputedHeight()).toBe(250);
expect(root_child4.getComputedLeft()).toBe(180);
expect(root_child4.getComputedTop()).toBe(270);
expect(root_child4.getComputedWidth()).toBe(200);
expect(root_child4.getComputedHeight()).toBe(250);
expect(root_child5.getComputedLeft()).toBe(-40);
expect(root_child5.getComputedTop()).toBe(270);
expect(root_child5.getComputedWidth()).toBe(200);
expect(root_child5.getComputedHeight()).toBe(250);
});
test('grid_dashboard_layout', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 220});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 70});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(500);
root.setHeight(600);
root.setGap(Gutter.All, 10);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(4);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth("100%");
root_child0.setHeight(70);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(1);
root_child1.setGridColumnEnd(2);
root_child1.setGridRowStart(2);
root_child1.setGridRowEnd(4);
root_child1.setWidth(220);
root_child1.setHeight("100%");
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(2);
root_child2.setGridColumnEnd(3);
root_child2.setGridRowStart(2);
root_child2.setGridRowEnd(3);
root_child2.setWidth("100%");
root_child2.setHeight("100%");
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(3);
root_child3.setGridColumnEnd(4);
root_child3.setGridRowStart(2);
root_child3.setGridRowEnd(3);
root_child3.setWidth("100%");
root_child3.setHeight("100%");
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setGridColumnStart(2);
root_child4.setGridColumnEnd(4);
root_child4.setGridRowStart(3);
root_child4.setGridRowEnd(4);
root_child4.setWidth("100%");
root_child4.setHeight("100%");
root.insertChild(root_child4, 4);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(500);
expect(root.getComputedHeight()).toBe(600);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(500);
expect(root_child0.getComputedHeight()).toBe(70);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(80);
expect(root_child1.getComputedWidth()).toBe(220);
expect(root_child1.getComputedHeight()).toBe(520);
expect(root_child2.getComputedLeft()).toBe(230);
expect(root_child2.getComputedTop()).toBe(80);
expect(root_child2.getComputedWidth()).toBe(130);
expect(root_child2.getComputedHeight()).toBe(255);
expect(root_child3.getComputedLeft()).toBe(370);
expect(root_child3.getComputedTop()).toBe(80);
expect(root_child3.getComputedWidth()).toBe(130);
expect(root_child3.getComputedHeight()).toBe(255);
expect(root_child4.getComputedLeft()).toBe(230);
expect(root_child4.getComputedTop()).toBe(345);
expect(root_child4.getComputedWidth()).toBe(270);
expect(root_child4.getComputedHeight()).toBe(255);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(500);
expect(root.getComputedHeight()).toBe(600);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(500);
expect(root_child0.getComputedHeight()).toBe(70);
expect(root_child1.getComputedLeft()).toBe(280);
expect(root_child1.getComputedTop()).toBe(80);
expect(root_child1.getComputedWidth()).toBe(220);
expect(root_child1.getComputedHeight()).toBe(520);
expect(root_child2.getComputedLeft()).toBe(140);
expect(root_child2.getComputedTop()).toBe(80);
expect(root_child2.getComputedWidth()).toBe(130);
expect(root_child2.getComputedHeight()).toBe(255);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(80);
expect(root_child3.getComputedWidth()).toBe(130);
expect(root_child3.getComputedHeight()).toBe(255);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(345);
expect(root_child4.getComputedWidth()).toBe(270);
expect(root_child4.getComputedHeight()).toBe(255);
});
test('grid_magazine_layout', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 300});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(900);
root.setHeight(700);
root.setGap(Gutter.All, 15);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(3);
root_child0.setWidth("100%");
root_child0.setHeight("100%");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(2);
root_child1.setGridColumnEnd(3);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(2);
root_child1.setWidth("100%");
root_child1.setHeight(300);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(2);
root_child2.setGridColumnEnd(3);
root_child2.setGridRowStart(2);
root_child2.setGridRowEnd(3);
root_child2.setWidth("100%");
root_child2.setHeight(200);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(1);
root_child3.setGridColumnEnd(3);
root_child3.setGridRowStart(3);
root_child3.setGridRowEnd(4);
root_child3.setWidth("100%");
root_child3.setHeight(200);
root.insertChild(root_child3, 3);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(900);
expect(root.getComputedHeight()).toBe(700);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(590);
expect(root_child0.getComputedHeight()).toBe(515);
expect(root_child1.getComputedLeft()).toBe(605);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(295);
expect(root_child1.getComputedHeight()).toBe(300);
expect(root_child2.getComputedLeft()).toBe(605);
expect(root_child2.getComputedTop()).toBe(315);
expect(root_child2.getComputedWidth()).toBe(295);
expect(root_child2.getComputedHeight()).toBe(200);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(530);
expect(root_child3.getComputedWidth()).toBe(900);
expect(root_child3.getComputedHeight()).toBe(200);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(900);
expect(root.getComputedHeight()).toBe(700);
expect(root_child0.getComputedLeft()).toBe(310);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(590);
expect(root_child0.getComputedHeight()).toBe(515);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(295);
expect(root_child1.getComputedHeight()).toBe(300);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(315);
expect(root_child2.getComputedWidth()).toBe(295);
expect(root_child2.getComputedHeight()).toBe(200);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(530);
expect(root_child3.getComputedWidth()).toBe(900);
expect(root_child3.getComputedHeight()).toBe(200);
});
test('grid_app_layout', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 60});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 60});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
root.setHeight(600);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth(60);
root_child0.setHeight(60);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(2);
root_child1.setGridColumnEnd(3);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(2);
root_child1.setWidth("100%");
root_child1.setHeight(60);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(1);
root_child2.setGridColumnEnd(2);
root_child2.setGridRowStart(2);
root_child2.setGridRowEnd(3);
root_child2.setWidth(60);
root_child2.setHeight("100%");
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(2);
root_child3.setGridColumnEnd(3);
root_child3.setGridRowStart(2);
root_child3.setGridRowEnd(3);
root_child3.setWidth("100%");
root_child3.setHeight("100%");
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setGridColumnStart(1);
root_child4.setGridColumnEnd(3);
root_child4.setGridRowStart(3);
root_child4.setGridRowEnd(4);
root_child4.setWidth("100%");
root_child4.setHeight(50);
root.insertChild(root_child4, 4);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(600);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(60);
expect(root_child0.getComputedHeight()).toBe(60);
expect(root_child1.getComputedLeft()).toBe(60);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(340);
expect(root_child1.getComputedHeight()).toBe(60);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(60);
expect(root_child2.getComputedWidth()).toBe(60);
expect(root_child2.getComputedHeight()).toBe(490);
expect(root_child3.getComputedLeft()).toBe(60);
expect(root_child3.getComputedTop()).toBe(60);
expect(root_child3.getComputedWidth()).toBe(340);
expect(root_child3.getComputedHeight()).toBe(490);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(550);
expect(root_child4.getComputedWidth()).toBe(400);
expect(root_child4.getComputedHeight()).toBe(50);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(600);
expect(root_child0.getComputedLeft()).toBe(340);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(60);
expect(root_child0.getComputedHeight()).toBe(60);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(340);
expect(root_child1.getComputedHeight()).toBe(60);
expect(root_child2.getComputedLeft()).toBe(340);
expect(root_child2.getComputedTop()).toBe(60);
expect(root_child2.getComputedWidth()).toBe(60);
expect(root_child2.getComputedHeight()).toBe(490);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(60);
expect(root_child3.getComputedWidth()).toBe(340);
expect(root_child3.getComputedHeight()).toBe(490);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(550);
expect(root_child4.getComputedWidth()).toBe(400);
expect(root_child4.getComputedHeight()).toBe(50);
});
test('grid_asymmetric_layout', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(600);
root.setHeight(600);
root.setGap(Gutter.All, 10);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(3);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth("100%");
root_child0.setHeight(200);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(3);
root_child1.setGridColumnEnd(4);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(3);
root_child1.setWidth("100%");
root_child1.setHeight("100%");
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(1);
root_child2.setGridColumnEnd(2);
root_child2.setGridRowStart(2);
root_child2.setGridRowEnd(4);
root_child2.setWidth("100%");
root_child2.setHeight("100%");
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(2);
root_child3.setGridColumnEnd(3);
root_child3.setGridRowStart(2);
root_child3.setGridRowEnd(3);
root_child3.setWidth("100%");
root_child3.setHeight(200);
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setGridColumnStart(2);
root_child4.setGridColumnEnd(4);
root_child4.setGridRowStart(3);
root_child4.setGridRowEnd(4);
root_child4.setWidth("100%");
root_child4.setHeight(200);
root.insertChild(root_child4, 4);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(600);
expect(root.getComputedHeight()).toBe(600);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(397);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child1.getComputedLeft()).toBe(407);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(193);
expect(root_child1.getComputedHeight()).toBe(410);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(210);
expect(root_child2.getComputedWidth()).toBe(193);
expect(root_child2.getComputedHeight()).toBe(410);
expect(root_child3.getComputedLeft()).toBe(203);
expect(root_child3.getComputedTop()).toBe(210);
expect(root_child3.getComputedWidth()).toBe(194);
expect(root_child3.getComputedHeight()).toBe(200);
expect(root_child4.getComputedLeft()).toBe(203);
expect(root_child4.getComputedTop()).toBe(420);
expect(root_child4.getComputedWidth()).toBe(397);
expect(root_child4.getComputedHeight()).toBe(200);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(600);
expect(root.getComputedHeight()).toBe(600);
expect(root_child0.getComputedLeft()).toBe(203);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(397);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(193);
expect(root_child1.getComputedHeight()).toBe(410);
expect(root_child2.getComputedLeft()).toBe(407);
expect(root_child2.getComputedTop()).toBe(210);
expect(root_child2.getComputedWidth()).toBe(193);
expect(root_child2.getComputedHeight()).toBe(410);
expect(root_child3.getComputedLeft()).toBe(203);
expect(root_child3.getComputedTop()).toBe(210);
expect(root_child3.getComputedWidth()).toBe(194);
expect(root_child3.getComputedHeight()).toBe(200);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(420);
expect(root_child4.getComputedWidth()).toBe(397);
expect(root_child4.getComputedHeight()).toBe(200);
});
test('grid_with_percentage_tracks', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 20});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
rootGridTemplateRows.push({type: GridTrackType.Percent, value: 40});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root.insertChild(root_child1, 1);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(50);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(50);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(20);
expect(root_child1.getComputedHeight()).toBe(50);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(50);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(50);
expect(root_child1.getComputedLeft()).toBe(-20);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(20);
expect(root_child1.getComputedHeight()).toBe(50);
});
test('grid_percentage_tracks_with_definite_size', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Auto});
rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 20});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
rootGridTemplateRows.push({type: GridTrackType.Percent, value: 40});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(300);
root.setHeight(300);
root.setGap(Gutter.All, "10%");
const root_child0 = Yoga.Node.create(config);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root.insertChild(root_child3, 3);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(300);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(0);
expect(root_child0.getComputedHeight()).toBe(50);
expect(root_child1.getComputedLeft()).toBe(30);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(60);
expect(root_child1.getComputedHeight()).toBe(50);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(80);
expect(root_child2.getComputedWidth()).toBe(0);
expect(root_child2.getComputedHeight()).toBe(120);
expect(root_child3.getComputedLeft()).toBe(30);
expect(root_child3.getComputedTop()).toBe(80);
expect(root_child3.getComputedWidth()).toBe(60);
expect(root_child3.getComputedHeight()).toBe(120);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(300);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(300);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(0);
expect(root_child0.getComputedHeight()).toBe(50);
expect(root_child1.getComputedLeft()).toBe(210);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(60);
expect(root_child1.getComputedHeight()).toBe(50);
expect(root_child2.getComputedLeft()).toBe(300);
expect(root_child2.getComputedTop()).toBe(80);
expect(root_child2.getComputedWidth()).toBe(0);
expect(root_child2.getComputedHeight()).toBe(120);
expect(root_child3.getComputedLeft()).toBe(210);
expect(root_child3.getComputedTop()).toBe(80);
expect(root_child3.getComputedWidth()).toBe(60);
expect(root_child3.getComputedHeight()).toBe(120);
});
test('grid_spanning_items_with_span', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Auto});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setGap(Gutter.All, 10);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStartSpan(2);
root_child0.setGridRowStartSpan(2);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root.insertChild(root_child3, 3);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(220);
expect(root.getComputedHeight()).toBe(420);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(110);
expect(root_child0.getComputedHeight()).toBe(310);
expect(root_child1.getComputedLeft()).toBe(120);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(120);
expect(root_child2.getComputedTop()).toBe(110);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(200);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(320);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(220);
expect(root.getComputedHeight()).toBe(420);
expect(root_child0.getComputedLeft()).toBe(110);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(110);
expect(root_child0.getComputedHeight()).toBe(310);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(110);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(200);
expect(root_child3.getComputedLeft()).toBe(120);
expect(root_child3.getComputedTop()).toBe(320);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(100);
});
test('grid_mixed_units', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 80});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 80});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(600);
root.setHeight(400);
root.setGap(Gutter.All, 10);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth(100);
root_child0.setHeight(80);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(2);
root_child1.setGridColumnEnd(4);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(2);
root_child1.setWidth("100%");
root_child1.setHeight(80);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(4);
root_child2.setGridColumnEnd(5);
root_child2.setGridRowStart(1);
root_child2.setGridRowEnd(2);
root_child2.setWidth(100);
root_child2.setHeight(80);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(1);
root_child3.setGridColumnEnd(3);
root_child3.setGridRowStart(2);
root_child3.setGridRowEnd(3);
root_child3.setWidth("100%");
root_child3.setHeight("100%");
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setGridColumnStart(3);
root_child4.setGridColumnEnd(5);
root_child4.setGridRowStart(2);
root_child4.setGridRowEnd(3);
root_child4.setWidth("100%");
root_child4.setHeight("100%");
root.insertChild(root_child4, 4);
const root_child5 = Yoga.Node.create(config);
root_child5.setGridColumnStart(1);
root_child5.setGridColumnEnd(5);
root_child5.setGridRowStart(3);
root_child5.setGridRowEnd(4);
root_child5.setWidth("100%");
root_child5.setHeight(80);
root.insertChild(root_child5, 5);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(600);
expect(root.getComputedHeight()).toBe(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(110);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(380);
expect(root_child1.getComputedHeight()).toBe(80);
expect(root_child2.getComputedLeft()).toBe(500);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(80);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(90);
expect(root_child3.getComputedWidth()).toBe(233);
expect(root_child3.getComputedHeight()).toBe(220);
expect(root_child4.getComputedLeft()).toBe(243);
expect(root_child4.getComputedTop()).toBe(90);
expect(root_child4.getComputedWidth()).toBe(357);
expect(root_child4.getComputedHeight()).toBe(220);
expect(root_child5.getComputedLeft()).toBe(0);
expect(root_child5.getComputedTop()).toBe(320);
expect(root_child5.getComputedWidth()).toBe(600);
expect(root_child5.getComputedHeight()).toBe(80);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(600);
expect(root.getComputedHeight()).toBe(400);
expect(root_child0.getComputedLeft()).toBe(500);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(110);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(380);
expect(root_child1.getComputedHeight()).toBe(80);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(80);
expect(root_child3.getComputedLeft()).toBe(367);
expect(root_child3.getComputedTop()).toBe(90);
expect(root_child3.getComputedWidth()).toBe(233);
expect(root_child3.getComputedHeight()).toBe(220);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(90);
expect(root_child4.getComputedWidth()).toBe(357);
expect(root_child4.getComputedHeight()).toBe(220);
expect(root_child5.getComputedLeft()).toBe(0);
expect(root_child5.getComputedTop()).toBe(320);
expect(root_child5.getComputedWidth()).toBe(600);
expect(root_child5.getComputedHeight()).toBe(80);
});
test('grid_overlapping_items', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(300);
root.setHeight(300);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(3);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(3);
root_child0.setWidth("100%");
root_child0.setHeight("100%");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(2);
root_child1.setGridColumnEnd(4);
root_child1.setGridRowStart(2);
root_child1.setGridRowEnd(4);
root_child1.setWidth("100%");
root_child1.setHeight("100%");
root.insertChild(root_child1, 1);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(300);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(200);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(300);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(100);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(200);
});
test('grid_implicit_rows', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
const rootGridAutoRows = [];
rootGridAutoRows.push({type: GridTrackType.Points, value: 80});
root.setGridAutoRows(rootGridAutoRows);
root.setWidth(200);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth(100);
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(2);
root_child1.setGridColumnEnd(3);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(2);
root_child1.setWidth(100);
root_child1.setHeight(100);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(1);
root_child2.setGridColumnEnd(2);
root_child2.setGridRowStart(2);
root_child2.setGridRowEnd(3);
root_child2.setWidth(100);
root_child2.setHeight(80);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(2);
root_child3.setGridColumnEnd(3);
root_child3.setGridRowStart(2);
root_child3.setGridRowEnd(3);
root_child3.setWidth(100);
root_child3.setHeight(80);
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setGridColumnStart(1);
root_child4.setGridColumnEnd(2);
root_child4.setGridRowStart(3);
root_child4.setGridRowEnd(4);
root_child4.setWidth(100);
root_child4.setHeight(80);
root.insertChild(root_child4, 4);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(200);
expect(root.getComputedHeight()).toBe(260);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(100);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(80);
expect(root_child3.getComputedLeft()).toBe(100);
expect(root_child3.getComputedTop()).toBe(100);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(80);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(180);
expect(root_child4.getComputedWidth()).toBe(100);
expect(root_child4.getComputedHeight()).toBe(80);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(200);
expect(root.getComputedHeight()).toBe(260);
expect(root_child0.getComputedLeft()).toBe(100);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(100);
expect(root_child2.getComputedTop()).toBe(100);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(80);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(100);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(80);
expect(root_child4.getComputedLeft()).toBe(100);
expect(root_child4.getComputedTop()).toBe(180);
expect(root_child4.getComputedWidth()).toBe(100);
expect(root_child4.getComputedHeight()).toBe(80);
});
test('grid_implicit_columns', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
const rootGridAutoColumns = [];
rootGridAutoColumns.push({type: GridTrackType.Points, value: 80});
root.setGridAutoColumns(rootGridAutoColumns);
root.setHeight(200);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth(100);
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(1);
root_child1.setGridColumnEnd(2);
root_child1.setGridRowStart(2);
root_child1.setGridRowEnd(3);
root_child1.setWidth(100);
root_child1.setHeight(100);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(2);
root_child2.setGridColumnEnd(3);
root_child2.setGridRowStart(1);
root_child2.setGridRowEnd(2);
root_child2.setWidth(80);
root_child2.setHeight(100);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(2);
root_child3.setGridColumnEnd(3);
root_child3.setGridRowStart(2);
root_child3.setGridRowEnd(3);
root_child3.setWidth(80);
root_child3.setHeight(100);
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setGridColumnStart(3);
root_child4.setGridColumnEnd(4);
root_child4.setGridRowStart(1);
root_child4.setGridRowEnd(2);
root_child4.setWidth(80);
root_child4.setHeight(100);
root.insertChild(root_child4, 4);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(260);
expect(root.getComputedHeight()).toBe(200);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(100);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(80);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(100);
expect(root_child3.getComputedTop()).toBe(100);
expect(root_child3.getComputedWidth()).toBe(80);
expect(root_child3.getComputedHeight()).toBe(100);
expect(root_child4.getComputedLeft()).toBe(180);
expect(root_child4.getComputedTop()).toBe(0);
expect(root_child4.getComputedWidth()).toBe(80);
expect(root_child4.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(260);
expect(root.getComputedHeight()).toBe(200);
expect(root_child0.getComputedLeft()).toBe(160);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(160);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(80);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(80);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(80);
expect(root_child3.getComputedTop()).toBe(100);
expect(root_child3.getComputedWidth()).toBe(80);
expect(root_child3.getComputedHeight()).toBe(100);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(0);
expect(root_child4.getComputedWidth()).toBe(80);
expect(root_child4.getComputedHeight()).toBe(100);
});
test('grid_complex_spanning', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
root.setHeight(400);
root.setGap(Gutter.All, 5);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(3);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(3);
root_child0.setWidth("100%");
root_child0.setHeight("100%");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(3);
root_child1.setGridColumnEnd(5);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(2);
root_child1.setWidth("100%");
root_child1.setHeight(100);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(3);
root_child2.setGridColumnEnd(4);
root_child2.setGridRowStart(2);
root_child2.setGridRowEnd(4);
root_child2.setWidth(100);
root_child2.setHeight("100%");
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(4);
root_child3.setGridColumnEnd(5);
root_child3.setGridRowStart(2);
root_child3.setGridRowEnd(3);
root_child3.setWidth(100);
root_child3.setHeight(100);
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setGridColumnStart(1);
root_child4.setGridColumnEnd(2);
root_child4.setGridRowStart(3);
root_child4.setGridRowEnd(5);
root_child4.setWidth(100);
root_child4.setHeight("100%");
root.insertChild(root_child4, 4);
const root_child5 = Yoga.Node.create(config);
root_child5.setGridColumnStart(2);
root_child5.setGridColumnEnd(3);
root_child5.setGridRowStart(3);
root_child5.setGridRowEnd(4);
root_child5.setWidth(100);
root_child5.setHeight(100);
root.insertChild(root_child5, 5);
const root_child6 = Yoga.Node.create(config);
root_child6.setGridColumnStart(2);
root_child6.setGridColumnEnd(5);
root_child6.setGridRowStart(4);
root_child6.setGridRowEnd(5);
root_child6.setWidth("100%");
root_child6.setHeight(100);
root.insertChild(root_child6, 6);
const root_child7 = Yoga.Node.create(config);
root_child7.setGridColumnStart(4);
root_child7.setGridColumnEnd(5);
root_child7.setGridRowStart(3);
root_child7.setGridRowEnd(4);
root_child7.setWidth(100);
root_child7.setHeight(100);
root.insertChild(root_child7, 7);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(205);
expect(root_child0.getComputedHeight()).toBe(205);
expect(root_child1.getComputedLeft()).toBe(210);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(205);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(210);
expect(root_child2.getComputedTop()).toBe(105);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(205);
expect(root_child3.getComputedLeft()).toBe(315);
expect(root_child3.getComputedTop()).toBe(105);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(100);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(210);
expect(root_child4.getComputedWidth()).toBe(100);
expect(root_child4.getComputedHeight()).toBe(205);
expect(root_child5.getComputedLeft()).toBe(105);
expect(root_child5.getComputedTop()).toBe(210);
expect(root_child5.getComputedWidth()).toBe(100);
expect(root_child5.getComputedHeight()).toBe(100);
expect(root_child6.getComputedLeft()).toBe(105);
expect(root_child6.getComputedTop()).toBe(315);
expect(root_child6.getComputedWidth()).toBe(310);
expect(root_child6.getComputedHeight()).toBe(100);
expect(root_child7.getComputedLeft()).toBe(315);
expect(root_child7.getComputedTop()).toBe(210);
expect(root_child7.getComputedWidth()).toBe(100);
expect(root_child7.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(400);
expect(root_child0.getComputedLeft()).toBe(195);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(205);
expect(root_child0.getComputedHeight()).toBe(205);
expect(root_child1.getComputedLeft()).toBe(-15);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(205);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(90);
expect(root_child2.getComputedTop()).toBe(105);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(205);
expect(root_child3.getComputedLeft()).toBe(-15);
expect(root_child3.getComputedTop()).toBe(105);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(100);
expect(root_child4.getComputedLeft()).toBe(300);
expect(root_child4.getComputedTop()).toBe(210);
expect(root_child4.getComputedWidth()).toBe(100);
expect(root_child4.getComputedHeight()).toBe(205);
expect(root_child5.getComputedLeft()).toBe(195);
expect(root_child5.getComputedTop()).toBe(210);
expect(root_child5.getComputedWidth()).toBe(100);
expect(root_child5.getComputedHeight()).toBe(100);
expect(root_child6.getComputedLeft()).toBe(-15);
expect(root_child6.getComputedTop()).toBe(315);
expect(root_child6.getComputedWidth()).toBe(310);
expect(root_child6.getComputedHeight()).toBe(100);
expect(root_child7.getComputedLeft()).toBe(-15);
expect(root_child7.getComputedTop()).toBe(210);
expect(root_child7.getComputedWidth()).toBe(100);
expect(root_child7.getComputedHeight()).toBe(100);
});
test('grid_sparse_placement', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
root.setHeight(300);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth(100);
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(3);
root_child1.setGridColumnEnd(4);
root_child1.setGridRowStart(2);
root_child1.setGridRowEnd(3);
root_child1.setWidth(100);
root_child1.setHeight(100);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(2);
root_child2.setGridColumnEnd(3);
root_child2.setGridRowStart(3);
root_child2.setGridRowEnd(4);
root_child2.setWidth(100);
root_child2.setHeight(100);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(4);
root_child3.setGridColumnEnd(5);
root_child3.setGridRowStart(1);
root_child3.setGridRowEnd(2);
root_child3.setWidth(100);
root_child3.setHeight(100);
root.insertChild(root_child3, 3);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(200);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(100);
expect(root_child2.getComputedTop()).toBe(200);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(300);
expect(root_child3.getComputedTop()).toBe(0);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(300);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(200);
expect(root_child2.getComputedTop()).toBe(200);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(0);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(100);
});
test('grid_negative_line_numbers', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(300);
root.setHeight(300);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(-1);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth("100%");
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(1);
root_child1.setGridColumnEnd(-2);
root_child1.setGridRowStart(2);
root_child1.setGridRowEnd(3);
root_child1.setWidth("100%");
root_child1.setHeight(100);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(-2);
root_child2.setGridColumnEnd(-1);
root_child2.setGridRowStart(2);
root_child2.setGridRowEnd(-1);
root_child2.setWidth(100);
root_child2.setHeight("100%");
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(1);
root_child3.setGridColumnEnd(2);
root_child3.setGridRowStart(-2);
root_child3.setGridRowEnd(-1);
root_child3.setWidth(100);
root_child3.setHeight(100);
root.insertChild(root_child3, 3);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(300);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(300);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(200);
expect(root_child2.getComputedTop()).toBe(100);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(200);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(200);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(300);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(300);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(100);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(200);
expect(root_child3.getComputedLeft()).toBe(200);
expect(root_child3.getComputedTop()).toBe(200);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(100);
});
test('grid_all_fractional_units', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 3});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 2});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
root.setHeight(600);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth("100%");
root_child0.setHeight("100%");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(2);
root_child1.setGridColumnEnd(3);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(2);
root_child1.setWidth("100%");
root_child1.setHeight("100%");
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(3);
root_child2.setGridColumnEnd(4);
root_child2.setGridRowStart(1);
root_child2.setGridRowEnd(4);
root_child2.setWidth("100%");
root_child2.setHeight("100%");
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(1);
root_child3.setGridColumnEnd(3);
root_child3.setGridRowStart(2);
root_child3.setGridRowEnd(3);
root_child3.setWidth("100%");
root_child3.setHeight("100%");
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setGridColumnStart(1);
root_child4.setGridColumnEnd(2);
root_child4.setGridRowStart(3);
root_child4.setGridRowEnd(4);
root_child4.setWidth("100%");
root_child4.setHeight("100%");
root.insertChild(root_child4, 4);
const root_child5 = Yoga.Node.create(config);
root_child5.setGridColumnStart(2);
root_child5.setGridColumnEnd(3);
root_child5.setGridRowStart(3);
root_child5.setGridRowEnd(4);
root_child5.setWidth("100%");
root_child5.setHeight("100%");
root.insertChild(root_child5, 5);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(600);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(300);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(600);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(100);
expect(root_child3.getComputedWidth()).toBe(300);
expect(root_child3.getComputedHeight()).toBe(300);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(400);
expect(root_child4.getComputedWidth()).toBe(100);
expect(root_child4.getComputedHeight()).toBe(200);
expect(root_child5.getComputedLeft()).toBe(100);
expect(root_child5.getComputedTop()).toBe(400);
expect(root_child5.getComputedWidth()).toBe(200);
expect(root_child5.getComputedHeight()).toBe(200);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(600);
expect(root_child0.getComputedLeft()).toBe(300);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(600);
expect(root_child3.getComputedLeft()).toBe(100);
expect(root_child3.getComputedTop()).toBe(100);
expect(root_child3.getComputedWidth()).toBe(300);
expect(root_child3.getComputedHeight()).toBe(300);
expect(root_child4.getComputedLeft()).toBe(300);
expect(root_child4.getComputedTop()).toBe(400);
expect(root_child4.getComputedWidth()).toBe(100);
expect(root_child4.getComputedHeight()).toBe(200);
expect(root_child5.getComputedLeft()).toBe(100);
expect(root_child5.getComputedTop()).toBe(400);
expect(root_child5.getComputedWidth()).toBe(200);
expect(root_child5.getComputedHeight()).toBe(200);
});
test('grid_uniform_cells', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
root.setHeight(300);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth("100%");
root_child0.setHeight("100%");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(2);
root_child1.setGridColumnEnd(3);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(2);
root_child1.setWidth("100%");
root_child1.setHeight("100%");
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(3);
root_child2.setGridColumnEnd(4);
root_child2.setGridRowStart(1);
root_child2.setGridRowEnd(2);
root_child2.setWidth("100%");
root_child2.setHeight("100%");
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(4);
root_child3.setGridColumnEnd(5);
root_child3.setGridRowStart(1);
root_child3.setGridRowEnd(2);
root_child3.setWidth("100%");
root_child3.setHeight("100%");
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setGridColumnStart(1);
root_child4.setGridColumnEnd(2);
root_child4.setGridRowStart(2);
root_child4.setGridRowEnd(3);
root_child4.setWidth("100%");
root_child4.setHeight("100%");
root.insertChild(root_child4, 4);
const root_child5 = Yoga.Node.create(config);
root_child5.setGridColumnStart(2);
root_child5.setGridColumnEnd(3);
root_child5.setGridRowStart(2);
root_child5.setGridRowEnd(3);
root_child5.setWidth("100%");
root_child5.setHeight("100%");
root.insertChild(root_child5, 5);
const root_child6 = Yoga.Node.create(config);
root_child6.setGridColumnStart(3);
root_child6.setGridColumnEnd(4);
root_child6.setGridRowStart(2);
root_child6.setGridRowEnd(3);
root_child6.setWidth("100%");
root_child6.setHeight("100%");
root.insertChild(root_child6, 6);
const root_child7 = Yoga.Node.create(config);
root_child7.setGridColumnStart(4);
root_child7.setGridColumnEnd(5);
root_child7.setGridRowStart(2);
root_child7.setGridRowEnd(3);
root_child7.setWidth("100%");
root_child7.setHeight("100%");
root.insertChild(root_child7, 7);
const root_child8 = Yoga.Node.create(config);
root_child8.setGridColumnStart(1);
root_child8.setGridColumnEnd(2);
root_child8.setGridRowStart(3);
root_child8.setGridRowEnd(4);
root_child8.setWidth("100%");
root_child8.setHeight("100%");
root.insertChild(root_child8, 8);
const root_child9 = Yoga.Node.create(config);
root_child9.setGridColumnStart(2);
root_child9.setGridColumnEnd(3);
root_child9.setGridRowStart(3);
root_child9.setGridRowEnd(4);
root_child9.setWidth("100%");
root_child9.setHeight("100%");
root.insertChild(root_child9, 9);
const root_child10 = Yoga.Node.create(config);
root_child10.setGridColumnStart(3);
root_child10.setGridColumnEnd(4);
root_child10.setGridRowStart(3);
root_child10.setGridRowEnd(4);
root_child10.setWidth("100%");
root_child10.setHeight("100%");
root.insertChild(root_child10, 10);
const root_child11 = Yoga.Node.create(config);
root_child11.setGridColumnStart(4);
root_child11.setGridColumnEnd(5);
root_child11.setGridRowStart(3);
root_child11.setGridRowEnd(4);
root_child11.setWidth("100%");
root_child11.setHeight("100%");
root.insertChild(root_child11, 11);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(200);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(300);
expect(root_child3.getComputedTop()).toBe(0);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(100);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(100);
expect(root_child4.getComputedWidth()).toBe(100);
expect(root_child4.getComputedHeight()).toBe(100);
expect(root_child5.getComputedLeft()).toBe(100);
expect(root_child5.getComputedTop()).toBe(100);
expect(root_child5.getComputedWidth()).toBe(100);
expect(root_child5.getComputedHeight()).toBe(100);
expect(root_child6.getComputedLeft()).toBe(200);
expect(root_child6.getComputedTop()).toBe(100);
expect(root_child6.getComputedWidth()).toBe(100);
expect(root_child6.getComputedHeight()).toBe(100);
expect(root_child7.getComputedLeft()).toBe(300);
expect(root_child7.getComputedTop()).toBe(100);
expect(root_child7.getComputedWidth()).toBe(100);
expect(root_child7.getComputedHeight()).toBe(100);
expect(root_child8.getComputedLeft()).toBe(0);
expect(root_child8.getComputedTop()).toBe(200);
expect(root_child8.getComputedWidth()).toBe(100);
expect(root_child8.getComputedHeight()).toBe(100);
expect(root_child9.getComputedLeft()).toBe(100);
expect(root_child9.getComputedTop()).toBe(200);
expect(root_child9.getComputedWidth()).toBe(100);
expect(root_child9.getComputedHeight()).toBe(100);
expect(root_child10.getComputedLeft()).toBe(200);
expect(root_child10.getComputedTop()).toBe(200);
expect(root_child10.getComputedWidth()).toBe(100);
expect(root_child10.getComputedHeight()).toBe(100);
expect(root_child11.getComputedLeft()).toBe(300);
expect(root_child11.getComputedTop()).toBe(200);
expect(root_child11.getComputedWidth()).toBe(100);
expect(root_child11.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(300);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(200);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(100);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(0);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(100);
expect(root_child4.getComputedLeft()).toBe(300);
expect(root_child4.getComputedTop()).toBe(100);
expect(root_child4.getComputedWidth()).toBe(100);
expect(root_child4.getComputedHeight()).toBe(100);
expect(root_child5.getComputedLeft()).toBe(200);
expect(root_child5.getComputedTop()).toBe(100);
expect(root_child5.getComputedWidth()).toBe(100);
expect(root_child5.getComputedHeight()).toBe(100);
expect(root_child6.getComputedLeft()).toBe(100);
expect(root_child6.getComputedTop()).toBe(100);
expect(root_child6.getComputedWidth()).toBe(100);
expect(root_child6.getComputedHeight()).toBe(100);
expect(root_child7.getComputedLeft()).toBe(0);
expect(root_child7.getComputedTop()).toBe(100);
expect(root_child7.getComputedWidth()).toBe(100);
expect(root_child7.getComputedHeight()).toBe(100);
expect(root_child8.getComputedLeft()).toBe(300);
expect(root_child8.getComputedTop()).toBe(200);
expect(root_child8.getComputedWidth()).toBe(100);
expect(root_child8.getComputedHeight()).toBe(100);
expect(root_child9.getComputedLeft()).toBe(200);
expect(root_child9.getComputedTop()).toBe(200);
expect(root_child9.getComputedWidth()).toBe(100);
expect(root_child9.getComputedHeight()).toBe(100);
expect(root_child10.getComputedLeft()).toBe(100);
expect(root_child10.getComputedTop()).toBe(200);
expect(root_child10.getComputedWidth()).toBe(100);
expect(root_child10.getComputedHeight()).toBe(100);
expect(root_child11.getComputedLeft()).toBe(0);
expect(root_child11.getComputedTop()).toBe(200);
expect(root_child11.getComputedWidth()).toBe(100);
expect(root_child11.getComputedHeight()).toBe(100);
});
test('grid_auto_placement_row', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(300);
root.setHeight(200);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(100);
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(100);
root_child1.setHeight(100);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(100);
root_child2.setHeight(100);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setWidth(100);
root_child3.setHeight(100);
root.insertChild(root_child3, 3);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(300);
expect(root.getComputedHeight()).toBe(200);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(200);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(100);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(300);
expect(root.getComputedHeight()).toBe(200);
expect(root_child0.getComputedLeft()).toBe(200);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(200);
expect(root_child3.getComputedTop()).toBe(100);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(100);
});
test('grid_large_spans', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(250);
root.setHeight(200);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(6);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth("100%");
root_child0.setHeight(50);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(1);
root_child1.setGridColumnEnd(3);
root_child1.setGridRowStart(2);
root_child1.setGridRowEnd(5);
root_child1.setWidth("100%");
root_child1.setHeight("100%");
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(3);
root_child2.setGridColumnEnd(6);
root_child2.setGridRowStart(2);
root_child2.setGridRowEnd(5);
root_child2.setWidth("100%");
root_child2.setHeight("100%");
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(250);
expect(root.getComputedHeight()).toBe(200);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(250);
expect(root_child0.getComputedHeight()).toBe(50);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(50);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(150);
expect(root_child2.getComputedLeft()).toBe(100);
expect(root_child2.getComputedTop()).toBe(50);
expect(root_child2.getComputedWidth()).toBe(150);
expect(root_child2.getComputedHeight()).toBe(150);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(250);
expect(root.getComputedHeight()).toBe(200);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(250);
expect(root_child0.getComputedHeight()).toBe(50);
expect(root_child1.getComputedLeft()).toBe(150);
expect(root_child1.getComputedTop()).toBe(50);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(150);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(50);
expect(root_child2.getComputedWidth()).toBe(150);
expect(root_child2.getComputedHeight()).toBe(150);
});
test('grid_unequal_fractions', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 3});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 2});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(600);
root.setHeight(300);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth("100%");
root_child0.setHeight("100%");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(2);
root_child1.setGridColumnEnd(3);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(2);
root_child1.setWidth("100%");
root_child1.setHeight("100%");
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(3);
root_child2.setGridColumnEnd(4);
root_child2.setGridRowStart(1);
root_child2.setGridRowEnd(3);
root_child2.setWidth("100%");
root_child2.setHeight("100%");
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(1);
root_child3.setGridColumnEnd(3);
root_child3.setGridRowStart(2);
root_child3.setGridRowEnd(3);
root_child3.setWidth("100%");
root_child3.setHeight("100%");
root.insertChild(root_child3, 3);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(600);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(300);
expect(root_child1.getComputedHeight()).toBe(200);
expect(root_child2.getComputedLeft()).toBe(400);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(200);
expect(root_child2.getComputedHeight()).toBe(300);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(200);
expect(root_child3.getComputedWidth()).toBe(400);
expect(root_child3.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(600);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(500);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child1.getComputedLeft()).toBe(200);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(300);
expect(root_child1.getComputedHeight()).toBe(200);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(200);
expect(root_child2.getComputedHeight()).toBe(300);
expect(root_child3.getComputedLeft()).toBe(200);
expect(root_child3.getComputedTop()).toBe(200);
expect(root_child3.getComputedWidth()).toBe(400);
expect(root_child3.getComputedHeight()).toBe(100);
});
test('grid_single_cell', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 300});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(300);
root.setHeight(200);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth(300);
root_child0.setHeight(200);
root.insertChild(root_child0, 0);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(300);
expect(root.getComputedHeight()).toBe(200);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(300);
expect(root_child0.getComputedHeight()).toBe(200);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(300);
expect(root.getComputedHeight()).toBe(200);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(300);
expect(root_child0.getComputedHeight()).toBe(200);
});
test('grid_single_column', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 150});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 120});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(200);
root.setHeight(470);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth(200);
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(1);
root_child1.setGridColumnEnd(2);
root_child1.setGridRowStart(2);
root_child1.setGridRowEnd(3);
root_child1.setWidth(200);
root_child1.setHeight(150);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(1);
root_child2.setGridColumnEnd(2);
root_child2.setGridRowStart(3);
root_child2.setGridRowEnd(4);
root_child2.setWidth(200);
root_child2.setHeight(100);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(1);
root_child3.setGridColumnEnd(2);
root_child3.setGridRowStart(4);
root_child3.setGridRowEnd(5);
root_child3.setWidth(200);
root_child3.setHeight(120);
root.insertChild(root_child3, 3);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(200);
expect(root.getComputedHeight()).toBe(470);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(150);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(250);
expect(root_child2.getComputedWidth()).toBe(200);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(350);
expect(root_child3.getComputedWidth()).toBe(200);
expect(root_child3.getComputedHeight()).toBe(120);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(200);
expect(root.getComputedHeight()).toBe(470);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(100);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(150);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(250);
expect(root_child2.getComputedWidth()).toBe(200);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(350);
expect(root_child3.getComputedWidth()).toBe(200);
expect(root_child3.getComputedHeight()).toBe(120);
});
test('grid_single_row', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 120});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(470);
root.setHeight(200);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth(100);
root_child0.setHeight(200);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(2);
root_child1.setGridColumnEnd(3);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(2);
root_child1.setWidth(150);
root_child1.setHeight(200);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(3);
root_child2.setGridColumnEnd(4);
root_child2.setGridRowStart(1);
root_child2.setGridRowEnd(2);
root_child2.setWidth(100);
root_child2.setHeight(200);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(4);
root_child3.setGridColumnEnd(5);
root_child3.setGridRowStart(1);
root_child3.setGridRowEnd(2);
root_child3.setWidth(120);
root_child3.setHeight(200);
root.insertChild(root_child3, 3);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(470);
expect(root.getComputedHeight()).toBe(200);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(200);
expect(root_child2.getComputedLeft()).toBe(250);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(200);
expect(root_child3.getComputedLeft()).toBe(350);
expect(root_child3.getComputedTop()).toBe(0);
expect(root_child3.getComputedWidth()).toBe(120);
expect(root_child3.getComputedHeight()).toBe(200);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(470);
expect(root.getComputedHeight()).toBe(200);
expect(root_child0.getComputedLeft()).toBe(370);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child1.getComputedLeft()).toBe(220);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(200);
expect(root_child2.getComputedLeft()).toBe(120);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(200);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(0);
expect(root_child3.getComputedWidth()).toBe(120);
expect(root_child3.getComputedHeight()).toBe(200);
});
test('grid_tall_narrow', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 50});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(200);
root.setHeight(400);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(2);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(5);
root_child0.setWidth(100);
root_child0.setHeight("100%");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(2);
root_child1.setGridColumnEnd(3);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(2);
root_child1.setWidth(100);
root_child1.setHeight(50);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(2);
root_child2.setGridColumnEnd(3);
root_child2.setGridRowStart(2);
root_child2.setGridRowEnd(3);
root_child2.setWidth(100);
root_child2.setHeight(50);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(2);
root_child3.setGridColumnEnd(3);
root_child3.setGridRowStart(3);
root_child3.setGridRowEnd(4);
root_child3.setWidth(100);
root_child3.setHeight(50);
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setGridColumnStart(2);
root_child4.setGridColumnEnd(3);
root_child4.setGridRowStart(4);
root_child4.setGridRowEnd(5);
root_child4.setWidth(100);
root_child4.setHeight(50);
root.insertChild(root_child4, 4);
const root_child5 = Yoga.Node.create(config);
root_child5.setGridColumnStart(1);
root_child5.setGridColumnEnd(3);
root_child5.setGridRowStart(5);
root_child5.setGridRowEnd(9);
root_child5.setWidth("100%");
root_child5.setHeight("100%");
root.insertChild(root_child5, 5);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(200);
expect(root.getComputedHeight()).toBe(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(50);
expect(root_child2.getComputedLeft()).toBe(100);
expect(root_child2.getComputedTop()).toBe(50);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(50);
expect(root_child3.getComputedLeft()).toBe(100);
expect(root_child3.getComputedTop()).toBe(100);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(50);
expect(root_child4.getComputedLeft()).toBe(100);
expect(root_child4.getComputedTop()).toBe(150);
expect(root_child4.getComputedWidth()).toBe(100);
expect(root_child4.getComputedHeight()).toBe(50);
expect(root_child5.getComputedLeft()).toBe(0);
expect(root_child5.getComputedTop()).toBe(200);
expect(root_child5.getComputedWidth()).toBe(200);
expect(root_child5.getComputedHeight()).toBe(200);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(200);
expect(root.getComputedHeight()).toBe(400);
expect(root_child0.getComputedLeft()).toBe(100);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(50);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(50);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(50);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(100);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(50);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(150);
expect(root_child4.getComputedWidth()).toBe(100);
expect(root_child4.getComputedHeight()).toBe(50);
expect(root_child5.getComputedLeft()).toBe(0);
expect(root_child5.getComputedTop()).toBe(200);
expect(root_child5.getComputedWidth()).toBe(200);
expect(root_child5.getComputedHeight()).toBe(200);
});
test('grid_wide_short', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
root.setHeight(200);
const root_child0 = Yoga.Node.create(config);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(5);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(2);
root_child0.setWidth("100%");
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setGridColumnStart(5);
root_child1.setGridColumnEnd(6);
root_child1.setGridRowStart(1);
root_child1.setGridRowEnd(3);
root_child1.setWidth(50);
root_child1.setHeight("100%");
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setGridColumnStart(6);
root_child2.setGridColumnEnd(7);
root_child2.setGridRowStart(1);
root_child2.setGridRowEnd(2);
root_child2.setWidth(50);
root_child2.setHeight(100);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setGridColumnStart(7);
root_child3.setGridColumnEnd(8);
root_child3.setGridRowStart(1);
root_child3.setGridRowEnd(2);
root_child3.setWidth(50);
root_child3.setHeight(100);
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setGridColumnStart(8);
root_child4.setGridColumnEnd(9);
root_child4.setGridRowStart(1);
root_child4.setGridRowEnd(2);
root_child4.setWidth(50);
root_child4.setHeight(100);
root.insertChild(root_child4, 4);
const root_child5 = Yoga.Node.create(config);
root_child5.setGridColumnStart(1);
root_child5.setGridColumnEnd(5);
root_child5.setGridRowStart(2);
root_child5.setGridRowEnd(3);
root_child5.setWidth("100%");
root_child5.setHeight(100);
root.insertChild(root_child5, 5);
const root_child6 = Yoga.Node.create(config);
root_child6.setGridColumnStart(6);
root_child6.setGridColumnEnd(9);
root_child6.setGridRowStart(2);
root_child6.setGridRowEnd(3);
root_child6.setWidth("100%");
root_child6.setHeight(100);
root.insertChild(root_child6, 6);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(200);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(200);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(50);
expect(root_child1.getComputedHeight()).toBe(200);
expect(root_child2.getComputedLeft()).toBe(250);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(50);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(300);
expect(root_child3.getComputedTop()).toBe(0);
expect(root_child3.getComputedWidth()).toBe(50);
expect(root_child3.getComputedHeight()).toBe(100);
expect(root_child4.getComputedLeft()).toBe(350);
expect(root_child4.getComputedTop()).toBe(0);
expect(root_child4.getComputedWidth()).toBe(50);
expect(root_child4.getComputedHeight()).toBe(100);
expect(root_child5.getComputedLeft()).toBe(0);
expect(root_child5.getComputedTop()).toBe(100);
expect(root_child5.getComputedWidth()).toBe(200);
expect(root_child5.getComputedHeight()).toBe(100);
expect(root_child6.getComputedLeft()).toBe(250);
expect(root_child6.getComputedTop()).toBe(100);
expect(root_child6.getComputedWidth()).toBe(150);
expect(root_child6.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(400);
expect(root.getComputedHeight()).toBe(200);
expect(root_child0.getComputedLeft()).toBe(200);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(150);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(50);
expect(root_child1.getComputedHeight()).toBe(200);
expect(root_child2.getComputedLeft()).toBe(100);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(50);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(50);
expect(root_child3.getComputedTop()).toBe(0);
expect(root_child3.getComputedWidth()).toBe(50);
expect(root_child3.getComputedHeight()).toBe(100);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(0);
expect(root_child4.getComputedWidth()).toBe(50);
expect(root_child4.getComputedHeight()).toBe(100);
expect(root_child5.getComputedLeft()).toBe(200);
expect(root_child5.getComputedTop()).toBe(100);
expect(root_child5.getComputedWidth()).toBe(200);
expect(root_child5.getComputedHeight()).toBe(100);
expect(root_child6.getComputedLeft()).toBe(0);
expect(root_child6.getComputedTop()).toBe(100);
expect(root_child6.getComputedWidth()).toBe(150);
expect(root_child6.getComputedHeight()).toBe(100);
});
test('grid_gap_percentage_definite_size_2', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setDisplay(Display.Grid);
const rootGridTemplateColumns = [];
rootGridTemplateColumns.push({type: GridTrackType.Auto});
rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 10});
rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 10});
rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 10});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Auto});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setGap(Gutter.Column, "70%");
root.setGap(Gutter.Row, "40%");
root.setBorder(Edge.All, 1);
const root_child0 = Yoga.Node.create(config);
root_child0.setPadding(Edge.All, 20);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(4);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPadding(Edge.All, 20);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPadding(Edge.All, 20);
root_child2.setGridColumnStart(2);
root_child2.setGridColumnEnd(5);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(82);
expect(root.getComputedHeight()).toBe(82);
expect(root_child0.getComputedLeft()).toBe(1);
expect(root_child0.getComputedTop()).toBe(1);
expect(root_child0.getComputedWidth()).toBe(128);
expect(root_child0.getComputedHeight()).toBe(40);
expect(root_child1.getComputedLeft()).toBe(185);
expect(root_child1.getComputedTop()).toBe(1);
expect(root_child1.getComputedWidth()).toBe(40);
expect(root_child1.getComputedHeight()).toBe(40);
expect(root_child2.getComputedLeft()).toBe(57);
expect(root_child2.getComputedTop()).toBe(73);
expect(root_child2.getComputedWidth()).toBe(136);
expect(root_child2.getComputedHeight()).toBe(40);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(82);
expect(root.getComputedHeight()).toBe(82);
expect(root_child0.getComputedLeft()).toBe(-47);
expect(root_child0.getComputedTop()).toBe(1);
expect(root_child0.getComputedWidth()).toBe(128);
expect(root_child0.getComputedHeight()).toBe(40);
expect(root_child1.getComputedLeft()).toBe(-143);
expect(root_child1.getComputedTop()).toBe(1);
expect(root_child1.getComputedWidth()).toBe(40);
expect(root_child1.getComputedHeight()).toBe(40);
expect(root_child2.getComputedLeft()).toBe(-111);
expect(root_child2.getComputedTop()).toBe(73);
expect(root_child2.getComputedWidth()).toBe(136);
expect(root_child2.getComputedHeight()).toBe(40);
});