import { getNodeChildAt, getNodeChildCount } from '@flighthq/node/contract'; import type { Node2D } from '@flighthq/scene2d/contract'; import { SpriteKind } from '@flighthq/scene2d/contract'; import { ShapeKind } from '@flighthq/shape/contract'; import { TextLabelKind } from '@flighthq/text/contract'; import { describe, expect, it } from 'vitest'; import type { LottieShapeItemHandler, LottieShapeItemKind } from './contract.scene2d-formats-types.ts'; import { LottieShapeItemKind as Kind } from './contract.scene2d-formats-types.ts'; import type { LottieDocument, LottieLayer, LottieShapePath } from './contract.scene2d-formats-types.ts'; import { createScene2DFromLottieDocument } from './lottieImport.ts'; import { lottieRectangleShapeItemHandler } from './lottieRectangleShapeItem.ts'; import { createLottieRegistry, getLottieShapeItemHandler } from './lottieRegistry.ts'; import { registerLottieShapeItemHandlers } from './lottieShapeItemHandlers.ts'; import { createLottieTestDocument, findLottieTestNodeByKind, lottieTestShapeLayer } from './lottieTestFixtures.ts'; import { createReadyImageResourceForTest } from './testHelper.ts'; // The registration check the family test also makes, kept here so each item's test can assert BOTH halves of its // identity: that the handler behaves, and that the zero-config family installs this exact function for its kind. function expectRegisteredShapeItem(kind: LottieShapeItemKind, handler: LottieShapeItemHandler): void { const registry = createLottieRegistry(); registerLottieShapeItemHandlers(registry); expect(getLottieShapeItemHandler(registry, kind)).toBe(handler); } // ★ MOVED, NOT REWRITTEN. These assertions lived beside eight other handlers' while this one's interpretation was a // one-line shim into the document core. They are unchanged: the point of the move is locality, and editing them at // the same time would make a behaviour change indistinguishable from a relocation. describe('lottieRectangleShapeItemHandler', () => { it('is the built-in Rectangle shape item handler', () => { expectRegisteredShapeItem(Kind.Rectangle, lottieRectangleShapeItemHandler); }); }); describe('lottieRectangleShapeItemHandler', () => { it('creates a rectangle path', () => { const result = createScene2DFromLottieDocument(createLottieTestDocument([lottieTestShapeLayer(1, 'rect')])); expect(findLottieTestNodeByKind(result.root, ShapeKind)).not.toBeNull(); }); });