Skip to content

Commit 4993e86

Browse files
pomfridaclaude
andcommitted
test(eds-core-react): update Button tests for data-selectable-space
- Update test expectations from data-size to data-selectable-space - Update icon-only button tests to use selectable space tokens - Remove test for data-icon-position attributes (no longer used) - Update snapshot Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent d3adc05 commit 4993e86

2 files changed

Lines changed: 10 additions & 16 deletions

File tree

packages/eds-core-react/src/components/next/Button/Button.test.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ describe('Button (next)', () => {
142142
expect(span).toHaveTextContent('Text Content')
143143
})
144144

145-
it('preserves child order and adds icon position attributes', () => {
145+
it('preserves child order', () => {
146146
render(
147147
<Button>
148148
<MockIcon />
@@ -159,8 +159,6 @@ describe('Button (next)', () => {
159159
// Get all icons using data-testid
160160
const icons = screen.getAllByTestId('mock-icon')
161161
expect(icons).toHaveLength(2)
162-
expect(icons[0]).toHaveAttribute('data-icon-position', 'left')
163-
expect(icons[1]).toHaveAttribute('data-icon-position', 'right')
164162
})
165163
})
166164

@@ -388,38 +386,34 @@ describe('Button (next)', () => {
388386
expect(button).toHaveAttribute('data-icon-only', 'true')
389387
})
390388

391-
it('uses generic space tokens for icon-only (default size)', () => {
389+
it('uses selectable space tokens for icon-only (default size)', () => {
392390
render(
393391
<Button icon aria-label="Add">
394392
<MockIcon />
395393
</Button>,
396394
)
397395
const button = screen.getByRole('button')
398-
expect(button).toHaveAttribute('data-horizontal-space', '2xs')
399-
expect(button).toHaveAttribute('data-vertical-space', '2xs')
400-
expect(button).not.toHaveAttribute('data-selectable-space')
396+
expect(button).toHaveAttribute('data-selectable-space', 'md')
401397
})
402398

403-
it('uses generic space tokens for icon-only (small size)', () => {
399+
it('uses selectable space tokens for icon-only (small size)', () => {
404400
render(
405401
<Button icon aria-label="Add" size="small">
406402
<MockIcon />
407403
</Button>,
408404
)
409405
const button = screen.getByRole('button')
410-
expect(button).toHaveAttribute('data-horizontal-space', '3xs')
411-
expect(button).toHaveAttribute('data-vertical-space', '3xs')
406+
expect(button).toHaveAttribute('data-selectable-space', 'sm')
412407
})
413408

414-
it('uses generic space tokens for icon-only (large size)', () => {
409+
it('uses selectable space tokens for icon-only (large size)', () => {
415410
render(
416411
<Button icon aria-label="Add" size="large">
417412
<MockIcon />
418413
</Button>,
419414
)
420415
const button = screen.getByRole('button')
421-
expect(button).toHaveAttribute('data-horizontal-space', 'xs')
422-
expect(button).toHaveAttribute('data-vertical-space', 'xs')
416+
expect(button).toHaveAttribute('data-selectable-space', 'lg')
423417
})
424418

425419
it('uses selectable space tokens for regular button', () => {
@@ -431,8 +425,6 @@ describe('Button (next)', () => {
431425
)
432426
const button = screen.getByRole('button')
433427
expect(button).toHaveAttribute('data-selectable-space', 'md')
434-
expect(button).not.toHaveAttribute('data-horizontal-space')
435-
expect(button).not.toHaveAttribute('data-vertical-space')
436428
})
437429

438430
it('renders icon child in icon-only mode', () => {

packages/eds-core-react/src/components/next/Button/__snapshots__/Button.test.tsx.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ exports[`Button (next) Rendering matches snapshot 1`] = `
55
<button
66
class="eds-button"
77
data-color-appearance="accent"
8+
data-font-family="ui"
89
data-font-size="md"
10+
data-line-height="squished"
911
data-selectable-space="md"
10-
data-space-proportions="squished"
1112
data-variant="primary"
1213
type="button"
1314
>
1415
<span
1516
data-baseline="center"
1617
data-font-family="ui"
1718
data-font-size="md"
19+
data-line-height="squished"
1820
>
1921
Click me
2022
</span>

0 commit comments

Comments
 (0)