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.
93 lines
3.0 KiB
TypeScript
93 lines
3.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<<699de5988787e9f48c7c0a2c40e00292>>
|
|
* generated by gentest/src/GentestDriver.ts from gentest/fixtures/grid_aspect_ratio_spanning_items.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_aspect_ratio_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: 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});
|
|
rootGridTemplateRows.push({type: GridTrackType.Auto});
|
|
root.setGridTemplateRows(rootGridTemplateRows);
|
|
root.setGap(Gutter.All, 10);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setAspectRatio(3);
|
|
root_child0.setGridColumnStart(1);
|
|
root_child0.setGridColumnEnd(3);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
|
root_child1.setWidth(150);
|
|
root_child1.setAspectRatio(1);
|
|
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(160);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(450);
|
|
expect(root_child0.getComputedHeight()).toBe(150);
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(320);
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
expect(root_child1.getComputedWidth()).toBe(150);
|
|
expect(root_child1.getComputedHeight()).toBe(150);
|
|
|
|
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(160);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(20);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(450);
|
|
expect(root_child0.getComputedHeight()).toBe(150);
|
|
|
|
expect(root_child1.getComputedLeft()).toBe(0);
|
|
expect(root_child1.getComputedTop()).toBe(0);
|
|
expect(root_child1.getComputedWidth()).toBe(150);
|
|
expect(root_child1.getComputedHeight()).toBe(150);
|
|
});
|