Skip to content

Commit ddc3b54

Browse files
committed
chore: convert stories to CSF3 and add data-font-size tests
1 parent 7f975f6 commit ddc3b54

2 files changed

Lines changed: 32 additions & 17 deletions

File tree

packages/eds-core-react/src/components/next/Link/Link.stories.tsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Meta, StoryFn } from '@storybook/react-vite'
2-
import { Link, type LinkProps } from '.'
1+
import type { Meta, StoryObj } from '@storybook/react-vite'
2+
import { Link } from '.'
33
import { Icon } from '../Icon'
44
import { external_link, arrow_forward } from '@equinor/eds-icons'
55

@@ -24,33 +24,34 @@ import { Link } from '@equinor/eds-core-react/next'
2424

2525
export default meta
2626

27-
export const Introduction: StoryFn<LinkProps> = (args) => {
28-
return (
29-
<Link href="#" {...args}>
30-
Link
31-
</Link>
32-
)
27+
type Story = StoryObj<typeof Link>
28+
29+
export const Introduction: Story = {
30+
args: {
31+
href: '#',
32+
children: 'Link',
33+
},
3334
}
3435

35-
export const Inline: StoryFn<LinkProps> = () => {
36-
return (
36+
export const Inline: Story = {
37+
render: () => (
3738
<p>
3839
This is a paragraph with an <Link href="#">inline link</Link> embedded in
3940
text.
4041
</p>
41-
)
42+
),
4243
}
4344

44-
export const Standalone: StoryFn<LinkProps> = () => {
45-
return (
45+
export const Standalone: Story = {
46+
render: () => (
4647
<Link href="#" variant="standalone">
4748
Standalone link
4849
</Link>
49-
)
50+
),
5051
}
5152

52-
export const WithIcons: StoryFn<LinkProps> = () => {
53-
return (
53+
export const WithIcons: Story = {
54+
render: () => (
5455
<div
5556
style={{
5657
display: 'flex',
@@ -73,5 +74,5 @@ export const WithIcons: StoryFn<LinkProps> = () => {
7374
<Icon data={external_link} />
7475
</Link>
7576
</div>
76-
)
77+
),
7778
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ describe('Link (next)', () => {
8181
'https://example.com',
8282
)
8383
})
84+
85+
it('sets data-font-size for standalone variant', () => {
86+
render(
87+
<Link href="#" variant="standalone">
88+
Link
89+
</Link>,
90+
)
91+
expect(screen.getByRole('link')).toHaveAttribute('data-font-size', 'md')
92+
})
93+
94+
it('does not set data-font-size for inline variant', () => {
95+
render(<Link href="#">Link</Link>)
96+
expect(screen.getByRole('link')).not.toHaveAttribute('data-font-size')
97+
})
8498
})
8599

86100
describe('Accessibility', () => {

0 commit comments

Comments
 (0)