Skip to content

Commit

Permalink
Adding a test to ensure absolute paths are correct for deeply nested …
Browse files Browse the repository at this point in the history
…containers.
  • Loading branch information
travist committed Dec 3, 2024
1 parent 68cf8c3 commit 7248a7d
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/utils/formUtil/__tests__/eachComponent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1041,4 +1041,45 @@ describe('eachComponent', function () {
);
expect(contentComponentsAmount).to.be.equal(1);
});

it('Should get the absolute paths correctly when iterating.', function () {
const form: any = {
key: 'form',
display: 'form',
components: [
{
type: 'container',
key: 'outer-container',
components: [
{
type: 'textfield',
key: 'textfield',
},
{
type: 'container',
key: 'inner-container',
components: [
{
type: 'textfield',
key: 'innerTextfield',
},
],
},
],
},
],
};
// when passed child components, absolute path returns relative to the parent component/
eachComponent(
form.components,
(component: Component, path: string, components, parent, paths) => {
if (component.key === 'innerTextfield') {
expect(paths?.dataPath).to.equal(
'outer-container.inner-container.innerTextfield',
'absolute path path is incomplete',
);
}
},
);
});
});

0 comments on commit 7248a7d

Please sign in to comment.