test: share scene variable helper
This commit is contained in:
parent
4c26536e69
commit
3a5b6a5c37
|
|
@ -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<typeof makeSceneGraph>,
|
||||
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 () => {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue