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.
119 lines
4.0 KiB
TypeScript
119 lines
4.0 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<<da518779afee469baa09e1b64dba1274>>
|
|
* generated by gentest/src/GentestDriver.ts from gentest/fixtures/grid_complex_mixed_spanning_alignment.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('complex_mixed_spanning_alignment', () => {
|
|
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);
|
|
root.setGap(Gutter.All, 10);
|
|
root.setJustifyContent(Justify.SpaceBetween);
|
|
root.setAlignContent(Align.Center);
|
|
|
|
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.setJustifySelf(Justify.End);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
|
root_child1.setWidth("100%");
|
|
root_child1.setHeight(80);
|
|
root_child1.setAlignSelf(Align.Center);
|
|
root.insertChild(root_child1, 1);
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
|
root_child2.setWidth("100%");
|
|
root_child2.setHeight(200);
|
|
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(600);
|
|
expect(root.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(250);
|
|
expect(root_child0.getComputedHeight()).toBe(80);
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(260);
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
expect(root_child1.getComputedWidth()).toBe(110);
|
|
expect(root_child1.getComputedHeight()).toBe(80);
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(0);
|
|
expect(root_child2.getComputedTop()).toBe(90);
|
|
expect(root_child2.getComputedWidth()).toBe(100);
|
|
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(350);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(250);
|
|
expect(root_child0.getComputedHeight()).toBe(80);
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(230);
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
expect(root_child1.getComputedWidth()).toBe(110);
|
|
expect(root_child1.getComputedHeight()).toBe(80);
|
|
|
|
expect(root_child2.getComputedLeft()).toBe(500);
|
|
expect(root_child2.getComputedTop()).toBe(90);
|
|
expect(root_child2.getComputedWidth()).toBe(100);
|
|
expect(root_child2.getComputedHeight()).toBe(200);
|
|
});
|