Files
yoga/javascript/tests/generated/grid_absolute_resolved_insets.test.ts
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

284 lines
11 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<<637e485fc2881a26f087306f97f7a29e>>
* generated by gentest/src/GentestDriver.ts from gentest/fixtures/grid_absolute_resolved_insets.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_absolute_resolved_insets', () => {
const config = Yoga.Config.create();
const root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
const root_child0 = Yoga.Node.create(config);
root_child0.setDisplay(Display.Grid);
root_child0.setWidth(200);
root_child0.setHeight(200);
root_child0.setBorder(Edge.All, 20);
root_child0.setPadding(Edge.All, 15);
root.insertChild(root_child0, 0);
const root_child0_child0 = Yoga.Node.create(config);
root_child0_child0.setPositionType(PositionType.Absolute);
root_child0_child0.setPositionAuto(Edge.Top);
root_child0_child0.setPositionAuto(Edge.Left);
root_child0.insertChild(root_child0_child0, 0);
const root_child0_child1 = Yoga.Node.create(config);
root_child0_child1.setPositionType(PositionType.Absolute);
root_child0_child1.setPosition(Edge.Top, 0);
root_child0_child1.setPosition(Edge.Left, 0);
root_child0.insertChild(root_child0_child1, 1);
const root_child0_child2 = Yoga.Node.create(config);
root_child0_child2.setPositionType(PositionType.Absolute);
root_child0_child2.setPosition(Edge.Top, "100%");
root_child0_child2.setPosition(Edge.Left, "100%");
root_child0.insertChild(root_child0_child2, 2);
const root_child0_child3 = Yoga.Node.create(config);
root_child0_child3.setPositionType(PositionType.Absolute);
root_child0_child3.setPosition(Edge.Bottom, "100%");
root_child0_child3.setPosition(Edge.Right, "100%");
root_child0.insertChild(root_child0_child3, 3);
const root_child0_child4 = Yoga.Node.create(config);
root_child0_child4.setPositionType(PositionType.Absolute);
root_child0_child4.setPosition(Edge.Top, 30);
root_child0_child4.setPosition(Edge.Left, 30);
root_child0.insertChild(root_child0_child4, 4);
const root_child0_child5 = Yoga.Node.create(config);
root_child0_child5.setPositionType(PositionType.Absolute);
root_child0_child5.setPosition(Edge.Top, 0);
root_child0_child5.setPosition(Edge.Left, 0);
root_child0_child5.setWidth("100%");
root_child0_child5.setHeight("100%");
root_child0.insertChild(root_child0_child5, 5);
const root_child1 = Yoga.Node.create(config);
root_child1.setDisplay(Display.Grid);
root_child1.setWidth(200);
root_child1.setHeight(200);
root_child1.setBorder(Edge.All, 20);
root_child1.setPadding(Edge.All, 15);
root_child1.setOverflow(Overflow.Scroll);
root.insertChild(root_child1, 1);
const root_child1_child0 = Yoga.Node.create(config);
root_child1_child0.setPositionType(PositionType.Absolute);
root_child1_child0.setPositionAuto(Edge.Top);
root_child1_child0.setPositionAuto(Edge.Left);
root_child1.insertChild(root_child1_child0, 0);
const root_child1_child1 = Yoga.Node.create(config);
root_child1_child1.setPositionType(PositionType.Absolute);
root_child1_child1.setPosition(Edge.Top, 0);
root_child1_child1.setPosition(Edge.Left, 0);
root_child1.insertChild(root_child1_child1, 1);
const root_child1_child2 = Yoga.Node.create(config);
root_child1_child2.setPositionType(PositionType.Absolute);
root_child1_child2.setPosition(Edge.Top, "100%");
root_child1_child2.setPosition(Edge.Left, "100%");
root_child1.insertChild(root_child1_child2, 2);
const root_child1_child3 = Yoga.Node.create(config);
root_child1_child3.setPositionType(PositionType.Absolute);
root_child1_child3.setPosition(Edge.Bottom, "100%");
root_child1_child3.setPosition(Edge.Right, "100%");
root_child1.insertChild(root_child1_child3, 3);
const root_child1_child4 = Yoga.Node.create(config);
root_child1_child4.setPositionType(PositionType.Absolute);
root_child1_child4.setPosition(Edge.Top, 30);
root_child1_child4.setPosition(Edge.Left, 30);
root_child1.insertChild(root_child1_child4, 4);
const root_child1_child5 = Yoga.Node.create(config);
root_child1_child5.setPositionType(PositionType.Absolute);
root_child1_child5.setPosition(Edge.Top, 0);
root_child1_child5.setPosition(Edge.Left, 0);
root_child1_child5.setWidth("100%");
root_child1_child5.setHeight("100%");
root_child1.insertChild(root_child1_child5, 5);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(200);
expect(root.getComputedHeight()).toBe(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child0_child0.getComputedLeft()).toBe(20);
expect(root_child0_child0.getComputedTop()).toBe(20);
expect(root_child0_child0.getComputedWidth()).toBe(0);
expect(root_child0_child0.getComputedHeight()).toBe(0);
expect(root_child0_child1.getComputedLeft()).toBe(20);
expect(root_child0_child1.getComputedTop()).toBe(20);
expect(root_child0_child1.getComputedWidth()).toBe(0);
expect(root_child0_child1.getComputedHeight()).toBe(0);
expect(root_child0_child2.getComputedLeft()).toBe(180);
expect(root_child0_child2.getComputedTop()).toBe(180);
expect(root_child0_child2.getComputedWidth()).toBe(0);
expect(root_child0_child2.getComputedHeight()).toBe(0);
expect(root_child0_child3.getComputedLeft()).toBe(20);
expect(root_child0_child3.getComputedTop()).toBe(20);
expect(root_child0_child3.getComputedWidth()).toBe(0);
expect(root_child0_child3.getComputedHeight()).toBe(0);
expect(root_child0_child4.getComputedLeft()).toBe(50);
expect(root_child0_child4.getComputedTop()).toBe(50);
expect(root_child0_child4.getComputedWidth()).toBe(0);
expect(root_child0_child4.getComputedHeight()).toBe(0);
expect(root_child0_child5.getComputedLeft()).toBe(20);
expect(root_child0_child5.getComputedTop()).toBe(20);
expect(root_child0_child5.getComputedWidth()).toBe(160);
expect(root_child0_child5.getComputedHeight()).toBe(160);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(200);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(200);
expect(root_child1_child0.getComputedLeft()).toBe(20);
expect(root_child1_child0.getComputedTop()).toBe(20);
expect(root_child1_child0.getComputedWidth()).toBe(0);
expect(root_child1_child0.getComputedHeight()).toBe(0);
expect(root_child1_child1.getComputedLeft()).toBe(20);
expect(root_child1_child1.getComputedTop()).toBe(20);
expect(root_child1_child1.getComputedWidth()).toBe(0);
expect(root_child1_child1.getComputedHeight()).toBe(0);
expect(root_child1_child2.getComputedLeft()).toBe(180);
expect(root_child1_child2.getComputedTop()).toBe(180);
expect(root_child1_child2.getComputedWidth()).toBe(0);
expect(root_child1_child2.getComputedHeight()).toBe(0);
expect(root_child1_child3.getComputedLeft()).toBe(20);
expect(root_child1_child3.getComputedTop()).toBe(20);
expect(root_child1_child3.getComputedWidth()).toBe(0);
expect(root_child1_child3.getComputedHeight()).toBe(0);
expect(root_child1_child4.getComputedLeft()).toBe(50);
expect(root_child1_child4.getComputedTop()).toBe(50);
expect(root_child1_child4.getComputedWidth()).toBe(0);
expect(root_child1_child4.getComputedHeight()).toBe(0);
expect(root_child1_child5.getComputedLeft()).toBe(20);
expect(root_child1_child5.getComputedTop()).toBe(20);
expect(root_child1_child5.getComputedWidth()).toBe(160);
expect(root_child1_child5.getComputedHeight()).toBe(160);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(200);
expect(root.getComputedHeight()).toBe(400);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child0_child0.getComputedLeft()).toBe(180);
expect(root_child0_child0.getComputedTop()).toBe(20);
expect(root_child0_child0.getComputedWidth()).toBe(0);
expect(root_child0_child0.getComputedHeight()).toBe(0);
expect(root_child0_child1.getComputedLeft()).toBe(20);
expect(root_child0_child1.getComputedTop()).toBe(20);
expect(root_child0_child1.getComputedWidth()).toBe(0);
expect(root_child0_child1.getComputedHeight()).toBe(0);
expect(root_child0_child2.getComputedLeft()).toBe(180);
expect(root_child0_child2.getComputedTop()).toBe(180);
expect(root_child0_child2.getComputedWidth()).toBe(0);
expect(root_child0_child2.getComputedHeight()).toBe(0);
expect(root_child0_child3.getComputedLeft()).toBe(20);
expect(root_child0_child3.getComputedTop()).toBe(20);
expect(root_child0_child3.getComputedWidth()).toBe(0);
expect(root_child0_child3.getComputedHeight()).toBe(0);
expect(root_child0_child4.getComputedLeft()).toBe(50);
expect(root_child0_child4.getComputedTop()).toBe(50);
expect(root_child0_child4.getComputedWidth()).toBe(0);
expect(root_child0_child4.getComputedHeight()).toBe(0);
expect(root_child0_child5.getComputedLeft()).toBe(20);
expect(root_child0_child5.getComputedTop()).toBe(20);
expect(root_child0_child5.getComputedWidth()).toBe(160);
expect(root_child0_child5.getComputedHeight()).toBe(160);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(200);
expect(root_child1.getComputedWidth()).toBe(200);
expect(root_child1.getComputedHeight()).toBe(200);
expect(root_child1_child0.getComputedLeft()).toBe(180);
expect(root_child1_child0.getComputedTop()).toBe(20);
expect(root_child1_child0.getComputedWidth()).toBe(0);
expect(root_child1_child0.getComputedHeight()).toBe(0);
expect(root_child1_child1.getComputedLeft()).toBe(20);
expect(root_child1_child1.getComputedTop()).toBe(20);
expect(root_child1_child1.getComputedWidth()).toBe(0);
expect(root_child1_child1.getComputedHeight()).toBe(0);
expect(root_child1_child2.getComputedLeft()).toBe(180);
expect(root_child1_child2.getComputedTop()).toBe(180);
expect(root_child1_child2.getComputedWidth()).toBe(0);
expect(root_child1_child2.getComputedHeight()).toBe(0);
expect(root_child1_child3.getComputedLeft()).toBe(20);
expect(root_child1_child3.getComputedTop()).toBe(20);
expect(root_child1_child3.getComputedWidth()).toBe(0);
expect(root_child1_child3.getComputedHeight()).toBe(0);
expect(root_child1_child4.getComputedLeft()).toBe(50);
expect(root_child1_child4.getComputedTop()).toBe(50);
expect(root_child1_child4.getComputedWidth()).toBe(0);
expect(root_child1_child4.getComputedHeight()).toBe(0);
expect(root_child1_child5.getComputedLeft()).toBe(20);
expect(root_child1_child5.getComputedTop()).toBe(20);
expect(root_child1_child5.getComputedWidth()).toBe(160);
expect(root_child1_child5.getComputedHeight()).toBe(160);
});