From 3a5b6a5c3797444f28ed1a09d6368f602f5813c9 Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Thu, 11 Jun 2026 23:07:38 +0300 Subject: [PATCH] test: share scene variable helper --- tests/engine/render/jsx/render-tree.test.ts | 29 +-------------------- tests/helpers/scene.ts | 29 ++++++++++++++++++++- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/engine/render/jsx/render-tree.test.ts b/tests/engine/render/jsx/render-tree.test.ts index 234501cad..879cc2ce2 100644 --- a/tests/engine/render/jsx/render-tree.test.ts +++ b/tests/engine/render/jsx/render-tree.test.ts @@ -25,34 +25,7 @@ import { } from '@open-pencil/core' import { expectDefined, getNodeOrThrow, childIdAt } from '#tests/helpers/assert' -import { makeSceneGraph } from '#tests/helpers/scene' - -function addTestColorVariable( - graph: ReturnType, - id: string, - name: string, - value = { r: 1, g: 1, b: 1, a: 1 } -): void { - if (!graph.variableCollections.has('colors')) { - graph.addCollection({ - id: 'colors', - name: 'Colors', - modes: [{ modeId: 'light', name: 'Light' }], - defaultModeId: 'light', - variableIds: [] - }) - } - - graph.addVariable({ - id, - name, - type: 'COLOR', - collectionId: 'colors', - valuesByMode: { light: value }, - description: '', - hiddenFromPublishing: false - }) -} +import { addTestColorVariable, makeSceneGraph } from '#tests/helpers/scene' describe('renderTree', () => { it('renders a simple frame', async () => { diff --git a/tests/helpers/scene.ts b/tests/helpers/scene.ts index 59d14798e..b329bd545 100644 --- a/tests/helpers/scene.ts +++ b/tests/helpers/scene.ts @@ -1,5 +1,5 @@ import { SceneGraph } from '@open-pencil/core' -import type { SceneNode } from '@open-pencil/core' +import type { Color, SceneNode } from '@open-pencil/core' export function makeSceneGraph(pageName = 'Test'): SceneGraph { const graph = new SceneGraph() @@ -11,6 +11,33 @@ export function firstPageId(graph: SceneGraph): string { return graph.getPages()[0].id } +export function addTestColorVariable( + graph: SceneGraph, + id: string, + name: string, + value: Color = { r: 1, g: 1, b: 1, a: 1 } +): void { + if (!graph.variableCollections.has('colors')) { + graph.addCollection({ + id: 'colors', + name: 'Colors', + modes: [{ modeId: 'light', name: 'Light' }], + defaultModeId: 'light', + variableIds: [] + }) + } + + graph.addVariable({ + id, + name, + type: 'COLOR', + collectionId: 'colors', + valuesByMode: { light: value }, + description: '', + hiddenFromPublishing: false + }) +} + export function createRect( graph: SceneGraph, parentId: string,