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

4783 lines
179 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<<03799cbefa1d1b4cb8735b65c06a57b5>>
* generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGGridTestFlows.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_indefinite_container_size_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.Percent, value: 40});
rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 50});
rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 80});
rootGridTemplateRows.push({type: GridTrackType.Percent, value: 80});
root.setGridTemplateRows(rootGridTemplateRows);
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.setPadding(Edge.All, 30);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setMinWidth(40);
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setBorder(Edge.All, 10);
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(100);
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(104);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(234);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(260);
expect(root_child2.getComputedHeight()).toBe(80);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(80);
expect(root_child3.getComputedWidth()).toBe(104);
expect(root_child3.getComputedHeight()).toBe(80);
expect(root_child4.getComputedLeft()).toBe(104);
expect(root_child4.getComputedTop()).toBe(80);
expect(root_child4.getComputedWidth()).toBe(130);
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(260);
expect(root.getComputedHeight()).toBe(100);
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(56);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(-234);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(260);
expect(root_child2.getComputedHeight()).toBe(80);
expect(root_child3.getComputedLeft()).toBe(156);
expect(root_child3.getComputedTop()).toBe(80);
expect(root_child3.getComputedWidth()).toBe(104);
expect(root_child3.getComputedHeight()).toBe(80);
expect(root_child4.getComputedLeft()).toBe(26);
expect(root_child4.getComputedTop()).toBe(80);
expect(root_child4.getComputedWidth()).toBe(130);
expect(root_child4.getComputedHeight()).toBe(80);
});
test('grid_definite_container_size_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.Percent, value: 40});
rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 50});
rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 80});
rootGridTemplateRows.push({type: GridTrackType.Percent, value: 80});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(300);
root.setHeight(300);
root.setGap(Gutter.Row, "10%");
root.setGap(Gutter.Column, "20%");
const root_child0 = Yoga.Node.create(config);
root_child0.setMinWidth(40);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setBorder(Edge.All, 40);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPadding(Edge.All, 40);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setMargin(Edge.All, "10%");
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(120);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(180);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(80);
expect(root_child2.getComputedLeft()).toBe(390);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(300);
expect(root_child2.getComputedHeight()).toBe(80);
expect(root_child3.getComputedLeft()).toBe(12);
expect(root_child3.getComputedTop()).toBe(122);
expect(root_child3.getComputedWidth()).toBe(96);
expect(root_child3.getComputedHeight()).toBe(216);
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(180);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(-30);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(80);
expect(root_child2.getComputedLeft()).toBe(-390);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(300);
expect(root_child2.getComputedHeight()).toBe(80);
expect(root_child3.getComputedLeft()).toBe(192);
expect(root_child3.getComputedTop()).toBe(122);
expect(root_child3.getComputedWidth()).toBe(96);
expect(root_child3.getComputedHeight()).toBe(216);
});
test('init_track_intrinsic_sizing', () => {
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});
rootGridTemplateColumns.push({type: GridTrackType.Auto});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Auto});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(500);
root.setHeight(300);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(100);
root_child0.setHeight(80);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(150);
root_child1.setHeight(90);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(120);
root_child2.setHeight(70);
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(500);
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(80);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(250);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(120);
expect(root_child2.getComputedHeight()).toBe(70);
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(300);
expect(root_child0.getComputedLeft()).toBe(400);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(250);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(130);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(120);
expect(root_child2.getComputedHeight()).toBe(70);
});
test('init_track_flexible_sizing', () => {
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: 1});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
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);
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(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(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(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(100);
});
test('init_track_mixed_sizing', () => {
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.Fr, value: 1});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 80});
rootGridTemplateRows.push({type: GridTrackType.Auto});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(600);
root.setHeight(400);
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(80);
root_child1.setHeight(60);
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(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(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(80);
expect(root_child1.getComputedHeight()).toBe(60);
expect(root_child2.getComputedLeft()).toBe(180);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(140);
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(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(420);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(80);
expect(root_child1.getComputedHeight()).toBe(60);
expect(root_child2.getComputedLeft()).toBe(280);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(140);
expect(root_child2.getComputedHeight()).toBe(80);
});
test('resolve_intrinsic_single_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.Auto});
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);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(120);
root_child0.setHeight(80);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(100);
root_child1.setHeight(90);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(140);
root_child2.setHeight(70);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setWidth(110);
root_child3.setHeight(85);
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setWidth(130);
root_child4.setHeight(95);
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(390);
expect(root.getComputedHeight()).toBe(185);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(120);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(250);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(140);
expect(root_child2.getComputedHeight()).toBe(70);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(90);
expect(root_child3.getComputedWidth()).toBe(110);
expect(root_child3.getComputedHeight()).toBe(85);
expect(root_child4.getComputedLeft()).toBe(120);
expect(root_child4.getComputedTop()).toBe(90);
expect(root_child4.getComputedWidth()).toBe(130);
expect(root_child4.getComputedHeight()).toBe(95);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(390);
expect(root.getComputedHeight()).toBe(185);
expect(root_child0.getComputedLeft()).toBe(270);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(170);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(140);
expect(root_child2.getComputedHeight()).toBe(70);
expect(root_child3.getComputedLeft()).toBe(280);
expect(root_child3.getComputedTop()).toBe(90);
expect(root_child3.getComputedWidth()).toBe(110);
expect(root_child3.getComputedHeight()).toBe(85);
expect(root_child4.getComputedLeft()).toBe(140);
expect(root_child4.getComputedTop()).toBe(90);
expect(root_child4.getComputedWidth()).toBe(130);
expect(root_child4.getComputedHeight()).toBe(95);
});
test('resolve_intrinsic_multi_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.Auto});
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});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(250);
root_child0.setHeight(100);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(3);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(80);
root_child1.setHeight(90);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(100);
root_child2.setHeight(110);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setWidth(300);
root_child3.setHeight(120);
root_child3.setGridColumnStart(2);
root_child3.setGridColumnEnd(4);
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(220);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(250);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(320);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(80);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(100);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(110);
expect(root_child3.getComputedLeft()).toBe(100);
expect(root_child3.getComputedTop()).toBe(100);
expect(root_child3.getComputedWidth()).toBe(300);
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(400);
expect(root.getComputedHeight()).toBe(220);
expect(root_child0.getComputedLeft()).toBe(150);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(250);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(80);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(300);
expect(root_child2.getComputedTop()).toBe(100);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(110);
expect(root_child3.getComputedLeft()).toBe(0);
expect(root_child3.getComputedTop()).toBe(100);
expect(root_child3.getComputedWidth()).toBe(300);
expect(root_child3.getComputedHeight()).toBe(120);
});
test('resolve_intrinsic_flexible_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.Auto});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateColumns.push({type: GridTrackType.Auto});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Auto});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(300);
root_child0.setHeight(80);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(3);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(100);
root_child1.setHeight(90);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(120);
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(400);
expect(root.getComputedHeight()).toBe(190);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(300);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(300);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(90);
expect(root_child2.getComputedWidth()).toBe(120);
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(400);
expect(root.getComputedHeight()).toBe(190);
expect(root_child0.getComputedLeft()).toBe(100);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(300);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(280);
expect(root_child2.getComputedTop()).toBe(90);
expect(root_child2.getComputedWidth()).toBe(120);
expect(root_child2.getComputedHeight()).toBe(100);
});
test('resolve_intrinsic_progressive_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.Auto});
rootGridTemplateColumns.push({type: GridTrackType.Auto});
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});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setGap(Gutter.All, 10);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(100);
root_child0.setHeight(80);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(110);
root_child1.setHeight(85);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(90);
root_child2.setHeight(75);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setWidth(105);
root_child3.setHeight(82);
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setWidth(250);
root_child4.setHeight(90);
root_child4.setGridColumnStart(1);
root_child4.setGridColumnEnd(3);
root_child4.setGridRowStart(2);
root.insertChild(root_child4, 4);
const root_child5 = Yoga.Node.create(config);
root_child5.setWidth(230);
root_child5.setHeight(95);
root_child5.setGridColumnStart(3);
root_child5.setGridColumnEnd(5);
root_child5.setGridRowStart(2);
root.insertChild(root_child5, 5);
const root_child6 = Yoga.Node.create(config);
root_child6.setWidth(380);
root_child6.setHeight(100);
root_child6.setGridColumnStart(1);
root_child6.setGridColumnEnd(4);
root_child6.setGridRowStart(3);
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(508);
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(80);
expect(root_child1.getComputedLeft()).toBe(131);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(110);
expect(root_child1.getComputedHeight()).toBe(85);
expect(root_child2.getComputedLeft()).toBe(272);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(90);
expect(root_child2.getComputedHeight()).toBe(75);
expect(root_child3.getComputedLeft()).toBe(390);
expect(root_child3.getComputedTop()).toBe(0);
expect(root_child3.getComputedWidth()).toBe(105);
expect(root_child3.getComputedHeight()).toBe(82);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(95);
expect(root_child4.getComputedWidth()).toBe(250);
expect(root_child4.getComputedHeight()).toBe(90);
expect(root_child5.getComputedLeft()).toBe(272);
expect(root_child5.getComputedTop()).toBe(95);
expect(root_child5.getComputedWidth()).toBe(230);
expect(root_child5.getComputedHeight()).toBe(95);
expect(root_child6.getComputedLeft()).toBe(0);
expect(root_child6.getComputedTop()).toBe(200);
expect(root_child6.getComputedWidth()).toBe(380);
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(508);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(408);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(267);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(110);
expect(root_child1.getComputedHeight()).toBe(85);
expect(root_child2.getComputedLeft()).toBe(146);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(90);
expect(root_child2.getComputedHeight()).toBe(75);
expect(root_child3.getComputedLeft()).toBe(13);
expect(root_child3.getComputedTop()).toBe(0);
expect(root_child3.getComputedWidth()).toBe(105);
expect(root_child3.getComputedHeight()).toBe(82);
expect(root_child4.getComputedLeft()).toBe(258);
expect(root_child4.getComputedTop()).toBe(95);
expect(root_child4.getComputedWidth()).toBe(250);
expect(root_child4.getComputedHeight()).toBe(90);
expect(root_child5.getComputedLeft()).toBe(6);
expect(root_child5.getComputedTop()).toBe(95);
expect(root_child5.getComputedWidth()).toBe(230);
expect(root_child5.getComputedHeight()).toBe(95);
expect(root_child6.getComputedLeft()).toBe(128);
expect(root_child6.getComputedTop()).toBe(200);
expect(root_child6.getComputedWidth()).toBe(380);
expect(root_child6.getComputedHeight()).toBe(100);
});
test('maximize_tracks_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.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.setWidth(500);
root.setHeight(300);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(100);
root_child0.setHeight(80);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(120);
root_child1.setHeight(90);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(110);
root_child2.setHeight(85);
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(500);
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(80);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(220);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(110);
expect(root_child2.getComputedHeight()).toBe(85);
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(300);
expect(root_child0.getComputedLeft()).toBe(400);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(280);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(170);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(110);
expect(root_child2.getComputedHeight()).toBe(85);
});
test('maximize_tracks_max_constraint', () => {
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});
rootGridTemplateColumns.push({type: GridTrackType.Auto});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Auto});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setMaxWidth(400);
root.setMaxHeight(250);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(150);
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(160);
root_child1.setHeight(110);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(170);
root_child2.setHeight(105);
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(110);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(150);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(160);
expect(root_child1.getComputedHeight()).toBe(110);
expect(root_child2.getComputedLeft()).toBe(310);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(170);
expect(root_child2.getComputedHeight()).toBe(105);
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(110);
expect(root_child0.getComputedLeft()).toBe(250);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(90);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(160);
expect(root_child1.getComputedHeight()).toBe(110);
expect(root_child2.getComputedLeft()).toBe(-80);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(170);
expect(root_child2.getComputedHeight()).toBe(105);
});
test('expand_flexible_definite_free_space', () => {
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);
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);
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(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(133);
expect(root_child1.getComputedHeight()).toBe(80);
expect(root_child2.getComputedLeft()).toBe(233);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(267);
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(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(367);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(133);
expect(root_child1.getComputedHeight()).toBe(80);
expect(root_child2.getComputedLeft()).toBe(100);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(267);
expect(root_child2.getComputedHeight()).toBe(80);
});
test('expand_flexible_min_constraint', () => {
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: 1});
root.setGridTemplateRows(rootGridTemplateRows);
root.setMinWidth(600);
root.setMinHeight(400);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(50);
root_child0.setHeight(50);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(60);
root_child1.setHeight(60);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(55);
root_child2.setHeight(55);
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(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(50);
expect(root_child0.getComputedHeight()).toBe(50);
expect(root_child1.getComputedLeft()).toBe(150);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(60);
expect(root_child1.getComputedHeight()).toBe(60);
expect(root_child2.getComputedLeft()).toBe(450);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(55);
expect(root_child2.getComputedHeight()).toBe(55);
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(550);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(50);
expect(root_child0.getComputedHeight()).toBe(50);
expect(root_child1.getComputedLeft()).toBe(390);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(60);
expect(root_child1.getComputedHeight()).toBe(60);
expect(root_child2.getComputedLeft()).toBe(95);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(55);
expect(root_child2.getComputedHeight()).toBe(55);
});
test('expand_flexible_max_constraint', () => {
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: 1});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(800);
root.setHeight(600);
root.setMaxWidth(500);
root.setMaxHeight(350);
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);
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(350);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(125);
expect(root_child0.getComputedHeight()).toBe(175);
expect(root_child1.getComputedLeft()).toBe(125);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(250);
expect(root_child1.getComputedHeight()).toBe(175);
expect(root_child2.getComputedLeft()).toBe(375);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(125);
expect(root_child2.getComputedHeight()).toBe(175);
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(350);
expect(root_child0.getComputedLeft()).toBe(375);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(125);
expect(root_child0.getComputedHeight()).toBe(175);
expect(root_child1.getComputedLeft()).toBe(125);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(250);
expect(root_child1.getComputedHeight()).toBe(175);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(125);
expect(root_child2.getComputedHeight()).toBe(175);
});
test('expand_flexible_flex_less_than_one', () => {
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: 0.5});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0.3});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0.2});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 0.6});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 0.4});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
root.setHeight(300);
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);
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(200);
expect(root_child0.getComputedHeight()).toBe(180);
expect(root_child1.getComputedLeft()).toBe(200);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(180);
expect(root_child2.getComputedLeft()).toBe(320);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(80);
expect(root_child2.getComputedHeight()).toBe(180);
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(200);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(180);
expect(root_child1.getComputedLeft()).toBe(80);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(180);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(80);
expect(root_child2.getComputedHeight()).toBe(180);
});
test('expand_flexible_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.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});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(600);
root.setHeight(400);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(450);
root_child0.setHeight("100%");
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(3);
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);
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(450);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child1.getComputedLeft()).toBe(450);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(200);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(200);
expect(root_child2.getComputedWidth()).toBe(225);
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(600);
expect(root.getComputedHeight()).toBe(400);
expect(root_child0.getComputedLeft()).toBe(150);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(450);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(200);
expect(root_child2.getComputedLeft()).toBe(375);
expect(root_child2.getComputedTop()).toBe(200);
expect(root_child2.getComputedWidth()).toBe(225);
expect(root_child2.getComputedHeight()).toBe(200);
});
test('stretch_auto_justify_content_stretch', () => {
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});
rootGridTemplateColumns.push({type: GridTrackType.Auto});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(600);
root.setHeight(200);
root.setJustifyContent(Justify.Stretch);
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(120);
root_child1.setHeight("100%");
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(110);
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(600);
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(190);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(400);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(110);
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(200);
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(290);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(90);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(110);
expect(root_child2.getComputedHeight()).toBe(100);
});
test('stretch_auto_align_content_stretch', () => {
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.Auto});
rootGridTemplateRows.push({type: GridTrackType.Auto});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(200);
root.setHeight(600);
root.setAlignContent(Align.Stretch);
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(120);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth("100%");
root_child2.setHeight(110);
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(200);
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(100);
expect(root_child1.getComputedHeight()).toBe(120);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(243);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(110);
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(600);
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(120);
expect(root_child2.getComputedLeft()).toBe(100);
expect(root_child2.getComputedTop()).toBe(243);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(110);
});
test('stretch_auto_both_axes', () => {
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});
rootGridTemplateColumns.push({type: GridTrackType.Auto});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Auto});
rootGridTemplateRows.push({type: GridTrackType.Auto});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(600);
root.setHeight(500);
root.setJustifyContent(Justify.Stretch);
root.setAlignContent(Align.Stretch);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(100);
root_child0.setHeight(80);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(120);
root_child1.setHeight(90);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(110);
root_child2.setHeight(85);
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(500);
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(190);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(400);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(110);
expect(root_child2.getComputedHeight()).toBe(85);
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(500);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(290);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(90);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(110);
expect(root_child2.getComputedHeight()).toBe(85);
});
test('justify_self_auto_margin_left', () => {
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});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
root.setHeight(100);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(100);
root_child0.setHeight("100%");
root_child0.setMargin(Edge.Left, "auto");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(100);
root_child1.setHeight("100%");
root_child1.setMargin(Edge.Left, "auto");
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(100);
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(300);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.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(100);
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(100);
expect(root_child1.getComputedHeight()).toBe(100);
});
test('justify_self_auto_margin_right', () => {
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});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
root.setHeight(100);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(100);
root_child0.setHeight("100%");
root_child0.setMargin(Edge.Right, "auto");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(100);
root_child1.setHeight("100%");
root_child1.setMargin(Edge.Right, "auto");
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(100);
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(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.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(100);
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(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
});
test('justify_self_auto_margin_both', () => {
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});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(400);
root.setHeight(100);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(100);
root_child0.setHeight("100%");
root_child0.setMargin(Edge.Left, "auto");
root_child0.setMargin(Edge.Right, "auto");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(100);
root_child1.setHeight("100%");
root_child1.setMargin(Edge.Left, "auto");
root_child1.setMargin(Edge.Right, "auto");
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(100);
expect(root_child0.getComputedLeft()).toBe(50);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(250);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.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(100);
expect(root_child0.getComputedLeft()).toBe(250);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(50);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
});
test('align_self_auto_margin_top', () => {
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: 200});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(100);
root.setHeight(400);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth("100%");
root_child0.setHeight(100);
root_child0.setMargin(Edge.Top, "auto");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth("100%");
root_child1.setHeight(100);
root_child1.setMargin(Edge.Top, "auto");
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(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(100);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(300);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
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(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(100);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(300);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
});
test('align_self_auto_margin_bottom', () => {
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: 200});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(100);
root.setHeight(400);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth("100%");
root_child0.setHeight(100);
root_child0.setMargin(Edge.Bottom, "auto");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth("100%");
root_child1.setHeight(100);
root_child1.setMargin(Edge.Bottom, "auto");
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(400);
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(200);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
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(400);
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(200);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
});
test('align_self_auto_margin_both', () => {
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: 200});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(100);
root.setHeight(400);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth("100%");
root_child0.setHeight(100);
root_child0.setMargin(Edge.Top, "auto");
root_child0.setMargin(Edge.Bottom, "auto");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth("100%");
root_child1.setHeight(100);
root_child1.setMargin(Edge.Top, "auto");
root_child1.setMargin(Edge.Bottom, "auto");
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(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(50);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(250);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
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(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(50);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(250);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
});
test('minimum_contribution_auto', () => {
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});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(120);
root_child0.setHeight(80);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(150);
root_child1.setHeight(90);
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(270);
expect(root.getComputedHeight()).toBe(90);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(120);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(90);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(270);
expect(root.getComputedHeight()).toBe(90);
expect(root_child0.getComputedLeft()).toBe(150);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(90);
});
test('minimum_contribution_definite', () => {
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});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(120);
root_child0.setHeight(80);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(150);
root_child1.setHeight(90);
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(270);
expect(root.getComputedHeight()).toBe(90);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(120);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(90);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(270);
expect(root.getComputedHeight()).toBe(90);
expect(root_child0.getComputedLeft()).toBe(150);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(90);
});
test('minimum_contribution_percentage_definite', () => {
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});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(500);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth("30%");
root_child0.setHeight(80);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth("40%");
root_child1.setHeight(90);
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(500);
expect(root.getComputedHeight()).toBe(90);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(0);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(0);
expect(root_child1.getComputedHeight()).toBe(90);
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(90);
expect(root_child0.getComputedLeft()).toBe(500);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(0);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(500);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(0);
expect(root_child1.getComputedHeight()).toBe(90);
});
test('minimum_contribution_min_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.Auto});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(120);
root_child0.setMinWidth(150);
root_child0.setHeight(80);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(100);
root_child1.setMinWidth(180);
root_child1.setHeight(90);
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(330);
expect(root.getComputedHeight()).toBe(90);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(150);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(180);
expect(root_child1.getComputedHeight()).toBe(90);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(330);
expect(root.getComputedHeight()).toBe(90);
expect(root_child0.getComputedLeft()).toBe(180);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(180);
expect(root_child1.getComputedHeight()).toBe(90);
});
test('content_based_min_definite_length', () => {
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});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(150);
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(180);
root_child1.setHeight(120);
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(330);
expect(root.getComputedHeight()).toBe(120);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(150);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(180);
expect(root_child1.getComputedHeight()).toBe(120);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(330);
expect(root.getComputedHeight()).toBe(120);
expect(root_child0.getComputedLeft()).toBe(180);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(180);
expect(root_child1.getComputedHeight()).toBe(120);
});
test('content_based_min_aspect_ratio', () => {
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});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(150);
root_child0.setAspectRatio(2);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setHeight(100);
root_child1.setAspectRatio(0.5);
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(200);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
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(100);
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(100);
expect(root_child0.getComputedLeft()).toBe(50);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(50);
expect(root_child1.getComputedHeight()).toBe(100);
});
test('content_based_min_content_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.Auto});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setPadding(Edge.All, 20);
root_child0.setWidth(100);
root_child0.setHeight(80);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPadding(Edge.All, 15);
root_child1.setWidth(120);
root_child1.setHeight(90);
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(220);
expect(root.getComputedHeight()).toBe(90);
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(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(90);
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(90);
expect(root_child0.getComputedLeft()).toBe(120);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(90);
});
test('content_based_min_fixed_track_clamp', () => {
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});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(300);
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(250);
root_child1.setHeight(120);
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(120);
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(200);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(250);
expect(root_child1.getComputedHeight()).toBe(120);
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(120);
expect(root_child0.getComputedLeft()).toBe(100);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(300);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(-50);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(250);
expect(root_child1.getComputedHeight()).toBe(120);
});
test('content_based_min_span_fixed_max', () => {
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: 150});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setGap(Gutter.All, 10);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(500);
root_child0.setHeight(100);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(3);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(100);
root_child1.setHeight(120);
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(470);
expect(root.getComputedHeight()).toBe(120);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(500);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(320);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(120);
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(120);
expect(root_child0.getComputedLeft()).toBe(-30);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(500);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(50);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(120);
});
test('max_content_contribution_basic', () => {
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});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(150);
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(180);
root_child1.setHeight(120);
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(330);
expect(root.getComputedHeight()).toBe(120);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(150);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(180);
expect(root_child1.getComputedHeight()).toBe(120);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(330);
expect(root.getComputedHeight()).toBe(120);
expect(root_child0.getComputedLeft()).toBe(180);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(180);
expect(root_child1.getComputedHeight()).toBe(120);
});
test('max_content_contribution_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.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(150);
root_child0.setHeight(100);
root_child0.setMargin(Edge.All, 10);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(180);
root_child1.setHeight(120);
root_child1.setMargin(Edge.All, 15);
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(380);
expect(root.getComputedHeight()).toBe(150);
expect(root_child0.getComputedLeft()).toBe(10);
expect(root_child0.getComputedTop()).toBe(10);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(185);
expect(root_child1.getComputedTop()).toBe(15);
expect(root_child1.getComputedWidth()).toBe(180);
expect(root_child1.getComputedHeight()).toBe(120);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(380);
expect(root.getComputedHeight()).toBe(150);
expect(root_child0.getComputedLeft()).toBe(220);
expect(root_child0.getComputedTop()).toBe(10);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(15);
expect(root_child1.getComputedTop()).toBe(15);
expect(root_child1.getComputedWidth()).toBe(180);
expect(root_child1.getComputedHeight()).toBe(120);
});
test('limited_min_content_fixed_limit', () => {
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: 150});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setGap(Gutter.All, 10);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(400);
root_child0.setHeight(100);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(3);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(100);
root_child1.setHeight(120);
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(310);
expect(root.getComputedHeight()).toBe(230);
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(110);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(120);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(310);
expect(root.getComputedHeight()).toBe(230);
expect(root_child0.getComputedLeft()).toBe(-90);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(400);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(210);
expect(root_child1.getComputedTop()).toBe(110);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(120);
});
test('limited_min_content_no_limit', () => {
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});
root.setGridTemplateRows(rootGridTemplateRows);
root.setGap(Gutter.All, 10);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(400);
root_child0.setHeight(100);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(3);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(100);
root_child1.setHeight(120);
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(230);
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(110);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(120);
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(230);
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(300);
expect(root_child1.getComputedTop()).toBe(110);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(120);
});
test('percentage_tracks_definite_container', () => {
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.Percent, value: 20});
rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 30});
rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 50});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Percent, value: 40});
rootGridTemplateRows.push({type: GridTrackType.Percent, value: 60});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(500);
root.setHeight(400);
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);
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(100);
expect(root_child0.getComputedHeight()).toBe(160);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(160);
expect(root_child2.getComputedLeft()).toBe(250);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(250);
expect(root_child2.getComputedHeight()).toBe(160);
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(400);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(160);
expect(root_child1.getComputedLeft()).toBe(250);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(160);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(250);
expect(root_child2.getComputedHeight()).toBe(160);
});
test('percentage_tracks_indefinite_container', () => {
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.Percent, value: 20});
rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 30});
rootGridTemplateColumns.push({type: GridTrackType.Auto});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Percent, value: 40});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(100);
root_child0.setHeight(80);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(120);
root_child1.setHeight(90);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(110);
root_child2.setHeight(85);
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(330);
expect(root.getComputedHeight()).toBe(90);
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(66);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(165);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(110);
expect(root_child2.getComputedHeight()).toBe(85);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(330);
expect(root.getComputedHeight()).toBe(90);
expect(root_child0.getComputedLeft()).toBe(230);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(144);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(120);
expect(root_child1.getComputedHeight()).toBe(90);
expect(root_child2.getComputedLeft()).toBe(55);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(110);
expect(root_child2.getComputedHeight()).toBe(85);
});
test('percentage_tracks_mixed_fixed', () => {
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: 30});
rootGridTemplateColumns.push({type: GridTrackType.Auto});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 80});
rootGridTemplateRows.push({type: GridTrackType.Percent, value: 40});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(500);
root.setHeight(400);
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);
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(100);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(80);
expect(root_child2.getComputedLeft()).toBe(250);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(0);
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(500);
expect(root.getComputedHeight()).toBe(400);
expect(root_child0.getComputedLeft()).toBe(400);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(80);
expect(root_child1.getComputedLeft()).toBe(250);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(80);
expect(root_child2.getComputedLeft()).toBe(250);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(0);
expect(root_child2.getComputedHeight()).toBe(80);
});
test('percentage_gap_definite_container', () => {
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: 150});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(600);
root.setHeight(300);
root.setGap(Gutter.Column, "10%");
root.setGap(Gutter.Row, "20%");
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);
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(150);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(210);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(420);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(150);
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(450);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(240);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(30);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(150);
expect(root_child2.getComputedHeight()).toBe(100);
});
test('spanning_items_span_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.Auto});
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.All, 10);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(250);
root_child0.setHeight(100);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(3);
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(110);
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(480);
expect(root.getComputedHeight()).toBe(110);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(250);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(260);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(370);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(110);
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(480);
expect(root.getComputedHeight()).toBe(110);
expect(root_child0.getComputedLeft()).toBe(230);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(250);
expect(root_child0.getComputedHeight()).toBe(100);
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(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(110);
expect(root_child2.getComputedHeight()).toBe(100);
});
test('spanning_items_span_3', () => {
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});
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.All, 10);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(380);
root_child0.setHeight(100);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(4);
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);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(490);
expect(root.getComputedHeight()).toBe(110);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(380);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(390);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(490);
expect(root.getComputedHeight()).toBe(110);
expect(root_child0.getComputedLeft()).toBe(110);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(380);
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);
});
test('spanning_items_overlapping', () => {
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});
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});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setGap(Gutter.All, 10);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(250);
root_child0.setHeight(100);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(3);
root_child0.setGridRowStart(1);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(280);
root_child1.setHeight(120);
root_child1.setGridColumnStart(2);
root_child1.setGridColumnEnd(4);
root_child1.setGridRowStart(2);
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(420);
expect(root.getComputedHeight()).toBe(240);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(250);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(130);
expect(root_child1.getComputedTop()).toBe(110);
expect(root_child1.getComputedWidth()).toBe(280);
expect(root_child1.getComputedHeight()).toBe(120);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(420);
expect(root.getComputedHeight()).toBe(240);
expect(root_child0.getComputedLeft()).toBe(170);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(250);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(10);
expect(root_child1.getComputedTop()).toBe(110);
expect(root_child1.getComputedWidth()).toBe(280);
expect(root_child1.getComputedHeight()).toBe(120);
});
test('spanning_items_both_axes', () => {
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});
rootGridTemplateColumns.push({type: GridTrackType.Auto});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Auto});
rootGridTemplateRows.push({type: GridTrackType.Auto});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
root.setGap(Gutter.All, 10);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(250);
root_child0.setHeight(230);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(3);
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.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth(110);
root_child2.setHeight(110);
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(370);
expect(root.getComputedHeight()).toBe(240);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(250);
expect(root_child0.getComputedHeight()).toBe(230);
expect(root_child1.getComputedLeft()).toBe(260);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(260);
expect(root_child2.getComputedTop()).toBe(115);
expect(root_child2.getComputedWidth()).toBe(110);
expect(root_child2.getComputedHeight()).toBe(110);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(370);
expect(root.getComputedHeight()).toBe(240);
expect(root_child0.getComputedLeft()).toBe(120);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(250);
expect(root_child0.getComputedHeight()).toBe(230);
expect(root_child1.getComputedLeft()).toBe(10);
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(115);
expect(root_child2.getComputedWidth()).toBe(110);
expect(root_child2.getComputedHeight()).toBe(110);
});
test('auto_margins_inline_left', () => {
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: 100});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(150);
root_child0.setHeight("100%");
root_child0.setMargin(Edge.Left, "auto");
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(100);
expect(root_child0.getComputedLeft()).toBe(150);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.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(100);
expect(root_child0.getComputedLeft()).toBe(150);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
});
test('auto_margins_inline_right', () => {
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: 100});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(150);
root_child0.setHeight("100%");
root_child0.setMargin(Edge.Right, "auto");
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(100);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.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(100);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
});
test('auto_margins_block_top', () => {
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: 300});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth("100%");
root_child0.setHeight(150);
root_child0.setMargin(Edge.Top, "auto");
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(100);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(150);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(150);
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(300);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(150);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(150);
});
test('auto_margins_block_bottom', () => {
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: 300});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth("100%");
root_child0.setHeight(150);
root_child0.setMargin(Edge.Bottom, "auto");
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(100);
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(150);
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(300);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(150);
});
test('auto_margins_overrides_justify_self', () => {
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: 100});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(150);
root_child0.setHeight("100%");
root_child0.setMargin(Edge.Left, "auto");
root_child0.setJustifySelf(Justify.Start);
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(100);
expect(root_child0.getComputedLeft()).toBe(150);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.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(100);
expect(root_child0.getComputedLeft()).toBe(150);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
});
test('auto_margins_overrides_align_self', () => {
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: 300});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth("100%");
root_child0.setHeight(150);
root_child0.setMargin(Edge.Top, "auto");
root_child0.setAlignSelf(Align.Start);
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(100);
expect(root.getComputedHeight()).toBe(300);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(150);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(150);
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(300);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(150);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(150);
});
test('min_max_constraints_min_width', () => {
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});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(80);
root_child0.setMinWidth(150);
root_child0.setHeight("100%");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(90);
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(240);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(150);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(90);
expect(root_child1.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(240);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(90);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(90);
expect(root_child1.getComputedHeight()).toBe(100);
});
test('min_max_constraints_max_width', () => {
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});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth("100%");
root_child0.setMaxWidth(120);
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);
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(100);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(200);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.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(100);
expect(root_child0.getComputedLeft()).toBe(280);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(120);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(100);
});
test('min_max_constraints_min_height', () => {
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.Auto});
rootGridTemplateRows.push({type: GridTrackType.Auto});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth("100%");
root_child0.setHeight(80);
root_child0.setMinHeight(150);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth("100%");
root_child1.setHeight(90);
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(240);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(150);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(150);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(90);
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(240);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(150);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(150);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(90);
});
test('min_max_constraints_max_height', () => {
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: 200});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 200});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth("100%");
root_child0.setHeight("100%");
root_child0.setMaxHeight(120);
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);
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(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(120);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(200);
expect(root_child1.getComputedWidth()).toBe(100);
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(100);
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(120);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(200);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(200);
});
test('min_max_constraints_both', () => {
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});
root.setGridTemplateRows(rootGridTemplateRows);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(80);
root_child0.setMinWidth(100);
root_child0.setMaxWidth(150);
root_child0.setHeight(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(200);
root_child1.setMinWidth(100);
root_child1.setMaxWidth(130);
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(230);
expect(root.getComputedHeight()).toBe(100);
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(130);
expect(root_child1.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(230);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(130);
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(130);
expect(root_child1.getComputedHeight()).toBe(100);
});
test('gaps_justify_space_between', () => {
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});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(500);
root.setHeight(100);
root.setGap(Gutter.Column, 20);
root.setJustifyContent(Justify.SpaceBetween);
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);
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(100);
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(0);
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(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(500);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(400);
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(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(100);
});
test('gaps_align_space_around', () => {
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});
rootGridTemplateRows.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(100);
root.setHeight(500);
root.setGap(Gutter.Row, 20);
root.setAlignContent(Align.SpaceAround);
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);
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(500);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(27);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(200);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(373);
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(100);
expect(root.getComputedHeight()).toBe(500);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(27);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(200);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(373);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(100);
});
test('gaps_both_space_evenly', () => {
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(500);
root.setHeight(500);
root.setGap(Gutter.All, 15);
root.setJustifyContent(Justify.SpaceEvenly);
root.setAlignContent(Align.SpaceEvenly);
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);
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(500);
expect(root_child0.getComputedLeft()).toBe(43);
expect(root_child0.getComputedTop()).toBe(43);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(200);
expect(root_child1.getComputedTop()).toBe(43);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(358);
expect(root_child2.getComputedTop()).toBe(43);
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(500);
expect(root.getComputedHeight()).toBe(500);
expect(root_child0.getComputedLeft()).toBe(358);
expect(root_child0.getComputedTop()).toBe(43);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(200);
expect(root_child1.getComputedTop()).toBe(43);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(43);
expect(root_child2.getComputedTop()).toBe(43);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(100);
});
test('gaps_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.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.setGap(Gutter.All, 20);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth("100%");
root_child0.setHeight("100%");
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(3);
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_child2.setGridRowStart(2);
root_child2.setGridRowEnd(4);
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(340);
expect(root.getComputedHeight()).toBe(340);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(220);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(240);
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(120);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(220);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(340);
expect(root.getComputedHeight()).toBe(340);
expect(root_child0.getComputedLeft()).toBe(120);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(220);
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(240);
expect(root_child2.getComputedTop()).toBe(120);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(220);
});
test('complex_flexible_min_max_distribution', () => {
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: 1});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(600);
root.setHeight(400);
root.setMinWidth(400);
root.setMaxWidth(800);
root.setGap(Gutter.All, 15);
root.setJustifyContent(Justify.SpaceAround);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth("100%");
root_child0.setHeight("100%");
root_child0.setMinWidth(150);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth("100%");
root_child1.setHeight("100%");
root_child1.setMaxWidth(250);
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(600);
expect(root.getComputedHeight()).toBe(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(193);
expect(root_child1.getComputedLeft()).toBe(165);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(250);
expect(root_child1.getComputedHeight()).toBe(193);
expect(root_child2.getComputedLeft()).toBe(460);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(140);
expect(root_child2.getComputedHeight()).toBe(193);
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(450);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(150);
expect(root_child0.getComputedHeight()).toBe(193);
expect(root_child1.getComputedLeft()).toBe(185);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(250);
expect(root_child1.getComputedHeight()).toBe(193);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(140);
expect(root_child2.getComputedHeight()).toBe(193);
});
test('complex_all_features_combined', () => {
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.Fr, value: 1});
rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2});
rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 30});
root.setGridTemplateColumns(rootGridTemplateColumns);
const rootGridTemplateRows = [];
rootGridTemplateRows.push({type: GridTrackType.Points, value: 80});
rootGridTemplateRows.push({type: GridTrackType.Auto});
rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1});
rootGridTemplateRows.push({type: GridTrackType.Percent, value: 40});
root.setGridTemplateRows(rootGridTemplateRows);
root.setWidth(800);
root.setHeight(600);
root.setGap(Gutter.All, 10);
root.setJustifyContent(Justify.SpaceEvenly);
root.setAlignContent(Align.SpaceBetween);
root.setJustifyItems(Justify.Center);
root.setAlignItems(Align.Center);
const root_child0 = Yoga.Node.create(config);
root_child0.setWidth(350);
root_child0.setHeight(180);
root_child0.setGridColumnStart(1);
root_child0.setGridColumnEnd(4);
root_child0.setGridRowStart(1);
root_child0.setGridRowEnd(3);
root_child0.setJustifySelf(Justify.Start);
root_child0.setAlignSelf(Align.End);
root_child0.setMargin(Edge.Left, 20);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setWidth(150);
root_child1.setAspectRatio(2);
root_child1.setMaxHeight(100);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setWidth("100%");
root_child2.setHeight("100%");
root_child2.setGridColumnStart(2);
root_child2.setGridColumnEnd(4);
root_child2.setMinWidth(200);
root_child2.setMaxWidth(300);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setAspectRatio(1);
root_child3.setMargin(Edge.All, "auto");
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setWidth("100%");
root_child4.setHeight("100%");
root_child4.setJustifySelf(Justify.Stretch);
root_child4.setAlignSelf(Align.Stretch);
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(800);
expect(root.getComputedHeight()).toBe(600);
expect(root_child0.getComputedLeft()).toBe(20);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(350);
expect(root_child0.getComputedHeight()).toBe(180);
expect(root_child1.getComputedLeft()).toBe(390);
expect(root_child1.getComputedTop()).toBe(3);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(75);
expect(root_child2.getComputedLeft()).toBe(110);
expect(root_child2.getComputedTop()).toBe(190);
expect(root_child2.getComputedWidth()).toBe(260);
expect(root_child2.getComputedHeight()).toBe(160);
expect(root_child3.getComputedLeft()).toBe(465);
expect(root_child3.getComputedTop()).toBe(270);
expect(root_child3.getComputedWidth()).toBe(0);
expect(root_child3.getComputedHeight()).toBe(0);
expect(root_child4.getComputedLeft()).toBe(560);
expect(root_child4.getComputedTop()).toBe(190);
expect(root_child4.getComputedWidth()).toBe(240);
expect(root_child4.getComputedHeight()).toBe(160);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(800);
expect(root.getComputedHeight()).toBe(600);
expect(root_child0.getComputedLeft()).toBe(450);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(350);
expect(root_child0.getComputedHeight()).toBe(180);
expect(root_child1.getComputedLeft()).toBe(260);
expect(root_child1.getComputedTop()).toBe(3);
expect(root_child1.getComputedWidth()).toBe(150);
expect(root_child1.getComputedHeight()).toBe(75);
expect(root_child2.getComputedLeft()).toBe(430);
expect(root_child2.getComputedTop()).toBe(190);
expect(root_child2.getComputedWidth()).toBe(260);
expect(root_child2.getComputedHeight()).toBe(160);
expect(root_child3.getComputedLeft()).toBe(335);
expect(root_child3.getComputedTop()).toBe(270);
expect(root_child3.getComputedWidth()).toBe(0);
expect(root_child3.getComputedHeight()).toBe(0);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(190);
expect(root_child4.getComputedWidth()).toBe(240);
expect(root_child4.getComputedHeight()).toBe(160);
});
test('grid_absolute_position_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);
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(50);
root_child1.setHeight(50);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Absolute);
root_child2.setWidth(100);
root_child2.setHeight(100);
root_child2.setPosition(Edge.Left, 50);
root_child2.setPosition(Edge.Top, 10);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setPositionType(PositionType.Absolute);
root_child3.setWidth(100);
root_child3.setHeight(100);
root_child3.setPosition(Edge.Left, 80);
root_child3.setPosition(Edge.Top, 10);
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(100);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(50);
expect(root_child1.getComputedHeight()).toBe(50);
expect(root_child2.getComputedLeft()).toBe(50);
expect(root_child2.getComputedTop()).toBe(10);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(80);
expect(root_child3.getComputedTop()).toBe(10);
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(200);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
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(50);
expect(root_child2.getComputedLeft()).toBe(50);
expect(root_child2.getComputedTop()).toBe(10);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(80);
expect(root_child3.getComputedTop()).toBe(10);
expect(root_child3.getComputedWidth()).toBe(100);
expect(root_child3.getComputedHeight()).toBe(100);
});
test('grid_item_with_display_contents_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);
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.setDisplay(Display.Contents);
root_child1.setBorder(Edge.All, 2);
root.insertChild(root_child1, 1);
const root_child1_child0 = Yoga.Node.create(config);
root_child1_child0.setWidth(100);
root_child1_child0.setHeight(100);
root_child1.insertChild(root_child1_child0, 0);
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(300);
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(0);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(0);
expect(root_child1.getComputedHeight()).toBe(0);
expect(root_child1_child0.getComputedLeft()).toBe(100);
expect(root_child1_child0.getComputedTop()).toBe(0);
expect(root_child1_child0.getComputedWidth()).toBe(100);
expect(root_child1_child0.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);
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(200);
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(0);
expect(root_child1.getComputedHeight()).toBe(0);
expect(root_child1_child0.getComputedLeft()).toBe(100);
expect(root_child1_child0.getComputedTop()).toBe(0);
expect(root_child1_child0.getComputedWidth()).toBe(100);
expect(root_child1_child0.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);
});
test('text_wraps_in_fixed_sized_column_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.Auto});
rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100});
root.setGridTemplateColumns(rootGridTemplateColumns);
const root_child0 = Yoga.Node.create(config);
root.insertChild(root_child0, 0);
root_child0.setMeasureFunc(intrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur", flexDirection: FlexDirection.Column}));
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(200);
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(0);
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(200);
expect(root.getComputedHeight()).toBe(50);
expect(root_child0.getComputedLeft()).toBe(100);
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(0);
expect(root_child1.getComputedHeight()).toBe(50);
});
test('text_wraps_in_fixed_sized_column_tracks_max_width', () => {
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 root_child0 = Yoga.Node.create(config);
root_child0.setMaxWidth(50);
root.insertChild(root_child0, 0);
root_child0.setMeasureFunc(intrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur", flexDirection: FlexDirection.Column}));
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(200);
expect(root.getComputedHeight()).toBe(60);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(50);
expect(root_child0.getComputedHeight()).toBe(60);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(0);
expect(root_child1.getComputedHeight()).toBe(60);
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(60);
expect(root_child0.getComputedLeft()).toBe(150);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(50);
expect(root_child0.getComputedHeight()).toBe(60);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(0);
expect(root_child1.getComputedHeight()).toBe(60);
});
test('text_wraps_in_fixed_sized_column_tracks_min_width', () => {
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 root_child0 = Yoga.Node.create(config);
root_child0.setMinWidth(180);
root_child0.setWidth(100);
root.insertChild(root_child0, 0);
root_child0.setMeasureFunc(intrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur", flexDirection: FlexDirection.Column}));
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(200);
expect(root.getComputedHeight()).toBe(30);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(180);
expect(root_child0.getComputedHeight()).toBe(30);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(0);
expect(root_child1.getComputedHeight()).toBe(30);
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(30);
expect(root_child0.getComputedLeft()).toBe(20);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(180);
expect(root_child0.getComputedHeight()).toBe(30);
expect(root_child1.getComputedLeft()).toBe(100);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(0);
expect(root_child1.getComputedHeight()).toBe(30);
});