/** * What the inspector of a *placed* behavior lists. A global variable has no value of this object's * own, so it gets no row here – the switch on the declaration is the only place it is edited. */ import { describe, expect, it } from 'vitest'; import { SetVariableScopeCommand } from '../../src/core/commands/variableCommands'; import { findAsset } from '../../src/core/model/Project'; import { objectRows } from '../../src/editor/inspector/objectSection'; import { makeBehavior, makeSpriteScene, place } from '../helpers'; describe('the rows of a placed behavior', () => { it('lists a local variable and leaves out a global one', () => { const f = makeSpriteScene(); const behavior = makeBehavior(f, 'Counter', ['score', 'lives']); const objectId = place(f, behavior.id, { x: 0, y: 0 }); const rows = () => { const asset = findAsset(f.project, behavior.id)!; return objectRows(f.project, asset, f.object(objectId)).map((def) => def.key); }; expect(rows()).toEqual(['score', 'lives']); f.stack.execute(new SetVariableScopeCommand(behavior.id, 'score', 'global')); expect(rows()).toEqual(['lives']); f.stack.undo(); expect(rows()).toEqual(['score', 'lives']); }); });