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 { lottiePolystarShapeItemHandler } from './lottiePolystarShapeItem.ts'; import { createLottieRegistry, getLottieShapeItemHandler } from './lottieRegistry.ts'; import { registerLottieShapeItemHandlers } from './lottieShapeItemHandlers.ts'; import { createLottieTestDocument, findLottieTestNodeByKind } 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('lottiePolystarShapeItemHandler', () => { it('is the built-in Polystar shape item handler', () => { expectRegisteredShapeItem(Kind.Polystar, lottiePolystarShapeItemHandler); }); }); describe('lottiePolystarShapeItemHandler', () => { it('creates a polystar path', () => { const result = createScene2DFromLottieDocument( createLottieTestDocument([ { ind: 1, ip: 0, nm: 'star', op: 60, shapes: [ { or: { k: 50 }, p: { k: [50, 50] }, pt: { k: 5 }, r: { k: 0 }, sy: 1, ir: { k: 25 }, ty: 'sr' }, { c: { k: [1, 0, 0] }, o: { k: 100 }, ty: 'fl' }, ], ty: 4, }, ]), ); expect(findLottieTestNodeByKind(result.root, ShapeKind)).not.toBeNull(); }); });