Skip to content

Commit

Permalink
assert label position relative to input
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Feb 26, 2025
1 parent a15a3d1 commit 456cece
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/form-layout/test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@ export function assertFormLayoutLabelPosition(layout, { position }) {
return;
}

const label = child.querySelector('[slot=label]');
const input = child.querySelector(':not([slot])');

if (position === 'aside') {
expect(child.offsetWidth).to.equal(columnWidth + labelWidth + labelSpacing, 'expected labels to be aside');
expect(child.offsetWidth).to.equal(
columnWidth + labelWidth + labelSpacing,
'expected column to have width equal to columnWidth + labelWidth + labelSpacing',
);
expect(label.offsetLeft).to.be.below(input.offsetLeft, 'expected label to be displayed aside input');
} else {
expect(child.offsetWidth).to.equal(columnWidth, 'expected labels to be above');
expect(child.offsetWidth).to.equal(columnWidth, 'expected column to have width equal to columnWidth');
expect(label.offsetTop).to.be.below(input.offsetTop, 'expected label to be displayed above input');
}
});
}

0 comments on commit 456cece

Please sign in to comment.