-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(composer): Auto expand hierarchy when selecting node on scene (#452)
* fix(composer): Auto expand hierarchy when selecting node on scene
- Loading branch information
1 parent
2b7cdb5
commit 9b3e80f
Showing
4 changed files
with
79 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ne-composer/src/components/panels/SceneHierarchyPanel/SceneHierarchyDataProvider.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import { useStore } from '../../../store'; | ||
|
||
import SceneHierarchyDataProvider, { Context } from './SceneHierarchyDataProvider'; | ||
|
||
describe('SceneHierarchyDataProvider', () => { | ||
const getSceneNodeByRef = jest.fn(); | ||
const baseState: any = { | ||
getSceneNodeByRef: jest.fn(), | ||
}; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it(`should return correct path from selected node to root`, () => { | ||
useStore('default').setState(baseState); | ||
baseState.getSceneNodeByRef.mockReturnValueOnce({ ref: 'node-1' }); | ||
baseState.getSceneNodeByRef.mockReturnValueOnce({ ref: 'sub-parent-1' }); | ||
baseState.getSceneNodeByRef.mockReturnValueOnce({ ref: 'parent-1' }); | ||
|
||
const expectedResult = ['sub-parent-1', 'parent-1']; | ||
|
||
const { getByText } = render( | ||
<SceneHierarchyDataProvider selectionMode='single'> | ||
<Context.Consumer> | ||
{(value) => <span>Path to root: {value.pathFromSelectedToRoot?.toString()}</span>} | ||
</Context.Consumer> | ||
</SceneHierarchyDataProvider>, | ||
); | ||
|
||
expect(baseState.getSceneNodeByRef).toBeCalledTimes(4); | ||
expect(getByText('Path to root: ' + expectedResult.toString())).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters