mirror of
https://github.com/hanzoai/yoga.git
synced 2026-10-30 19:34:29 +00:00
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.
196 lines
7.6 KiB
TypeScript
196 lines
7.6 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<<f63ff799f66b1116e3ef31f625d3081e>>
|
|
* generated by gentest/src/GentestDriver.ts from gentest/fixtures/grid_fr_single_item_indefinite.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_fr_single_item_indefinite', () => {
|
|
const config = Yoga.Config.create();
|
|
|
|
const root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
root.setWidth("max-content");
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth("auto");
|
|
root_child0.setHeight("auto");
|
|
root_child0.setDisplay(Display.Grid);
|
|
const root_child0GridTemplateColumns = [];
|
|
root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40});
|
|
root_child0GridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
|
|
root_child0GridTemplateColumns.push({type: GridTrackType.Fr, value: 1});
|
|
root_child0.setGridTemplateColumns(root_child0GridTemplateColumns);
|
|
const root_child0GridTemplateRows = [];
|
|
root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40});
|
|
root_child0GridTemplateRows.push({type: GridTrackType.Fr, value: 1});
|
|
root_child0GridTemplateRows.push({type: GridTrackType.Fr, value: 1});
|
|
root_child0.setGridTemplateRows(root_child0GridTemplateRows);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child1 = Yoga.Node.create(config);
|
|
root_child0_child1.setWidth(100);
|
|
root_child0.insertChild(root_child0_child1, 1);
|
|
|
|
const root_child0_child2 = Yoga.Node.create(config);
|
|
root_child0.insertChild(root_child0_child2, 2);
|
|
|
|
const root_child0_child3 = Yoga.Node.create(config);
|
|
root_child0.insertChild(root_child0_child3, 3);
|
|
|
|
const root_child0_child4 = Yoga.Node.create(config);
|
|
root_child0.insertChild(root_child0_child4, 4);
|
|
|
|
const root_child0_child5 = Yoga.Node.create(config);
|
|
root_child0.insertChild(root_child0_child5, 5);
|
|
|
|
const root_child0_child6 = Yoga.Node.create(config);
|
|
root_child0.insertChild(root_child0_child6, 6);
|
|
|
|
const root_child0_child7 = Yoga.Node.create(config);
|
|
root_child0.insertChild(root_child0_child7, 7);
|
|
|
|
const root_child0_child8 = Yoga.Node.create(config);
|
|
root_child0.insertChild(root_child0_child8, 8);
|
|
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(40);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(240);
|
|
expect(root_child0.getComputedHeight()).toBe(40);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(40);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(40);
|
|
|
|
expect(root_child0_child1.getComputedLeft()).toBe(40);
|
|
expect(root_child0_child1.getComputedTop()).toBe(0);
|
|
expect(root_child0_child1.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child1.getComputedHeight()).toBe(40);
|
|
|
|
expect(root_child0_child2.getComputedLeft()).toBe(140);
|
|
expect(root_child0_child2.getComputedTop()).toBe(0);
|
|
expect(root_child0_child2.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child2.getComputedHeight()).toBe(40);
|
|
|
|
expect(root_child0_child3.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child3.getComputedTop()).toBe(40);
|
|
expect(root_child0_child3.getComputedWidth()).toBe(40);
|
|
expect(root_child0_child3.getComputedHeight()).toBe(0);
|
|
|
|
expect(root_child0_child4.getComputedLeft()).toBe(40);
|
|
expect(root_child0_child4.getComputedTop()).toBe(40);
|
|
expect(root_child0_child4.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child4.getComputedHeight()).toBe(0);
|
|
|
|
expect(root_child0_child5.getComputedLeft()).toBe(140);
|
|
expect(root_child0_child5.getComputedTop()).toBe(40);
|
|
expect(root_child0_child5.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child5.getComputedHeight()).toBe(0);
|
|
|
|
expect(root_child0_child6.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child6.getComputedTop()).toBe(40);
|
|
expect(root_child0_child6.getComputedWidth()).toBe(40);
|
|
expect(root_child0_child6.getComputedHeight()).toBe(0);
|
|
|
|
expect(root_child0_child7.getComputedLeft()).toBe(40);
|
|
expect(root_child0_child7.getComputedTop()).toBe(40);
|
|
expect(root_child0_child7.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child7.getComputedHeight()).toBe(0);
|
|
|
|
expect(root_child0_child8.getComputedLeft()).toBe(140);
|
|
expect(root_child0_child8.getComputedTop()).toBe(40);
|
|
expect(root_child0_child8.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child8.getComputedHeight()).toBe(0);
|
|
|
|
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(40);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(240);
|
|
expect(root_child0.getComputedHeight()).toBe(40);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(200);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(40);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(40);
|
|
|
|
expect(root_child0_child1.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child1.getComputedTop()).toBe(0);
|
|
expect(root_child0_child1.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child1.getComputedHeight()).toBe(40);
|
|
|
|
expect(root_child0_child2.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child2.getComputedTop()).toBe(0);
|
|
expect(root_child0_child2.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child2.getComputedHeight()).toBe(40);
|
|
|
|
expect(root_child0_child3.getComputedLeft()).toBe(200);
|
|
expect(root_child0_child3.getComputedTop()).toBe(40);
|
|
expect(root_child0_child3.getComputedWidth()).toBe(40);
|
|
expect(root_child0_child3.getComputedHeight()).toBe(0);
|
|
|
|
expect(root_child0_child4.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child4.getComputedTop()).toBe(40);
|
|
expect(root_child0_child4.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child4.getComputedHeight()).toBe(0);
|
|
|
|
expect(root_child0_child5.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child5.getComputedTop()).toBe(40);
|
|
expect(root_child0_child5.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child5.getComputedHeight()).toBe(0);
|
|
|
|
expect(root_child0_child6.getComputedLeft()).toBe(200);
|
|
expect(root_child0_child6.getComputedTop()).toBe(40);
|
|
expect(root_child0_child6.getComputedWidth()).toBe(40);
|
|
expect(root_child0_child6.getComputedHeight()).toBe(0);
|
|
|
|
expect(root_child0_child7.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child7.getComputedTop()).toBe(40);
|
|
expect(root_child0_child7.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child7.getComputedHeight()).toBe(0);
|
|
|
|
expect(root_child0_child8.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child8.getComputedTop()).toBe(40);
|
|
expect(root_child0_child8.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child8.getComputedHeight()).toBe(0);
|
|
});
|