Skip to content

Commit 4744ea6

Browse files
committed
fixup! Transform Action jest tests into playwright (#592)
1 parent 8ae8682 commit 4744ea6

File tree

2 files changed

+68
-68
lines changed

2 files changed

+68
-68
lines changed

src/components/TextLink/__tests__/TextLink.spec.tsx

+66-66
Original file line numberDiff line numberDiff line change
@@ -7,78 +7,78 @@ import { propTests } from '../../../../tests/playwright';
77
import { TextLinkForTest } from './TextLink.story';
88

99
test.describe('TextLink', () => {
10-
test.describe('visual', () => {
11-
[
12-
...propTests.labelPropTest
13-
].forEach(({
14-
name,
15-
onBeforeTest,
16-
props,
10+
test.describe('visual', () => {
11+
[
12+
...propTests.labelPropTest,
13+
].forEach(({
14+
name,
15+
onBeforeTest,
16+
props,
17+
}) => {
18+
test(name, async ({
19+
mount,
20+
page,
1721
}) => {
18-
test(name, async ({
19-
mount,
20-
page
21-
}) => {
22-
if (onBeforeTest) {
23-
await onBeforeTest(page);
24-
}
22+
if (onBeforeTest) {
23+
await onBeforeTest(page);
24+
}
2525

26-
const component = await mount(
27-
<TextLinkForTest
28-
{...props}
29-
/>
30-
);
31-
32-
const screenshot = await component.screenshot();
33-
expect(screenshot).toMatchSnapshot();
34-
});
35-
});
36-
})
37-
38-
test.describe('non-visual', () => {
39-
test('href', async ({ mount }) => {
4026
const component = await mount(
4127
<TextLinkForTest
42-
href='/test/uri'
43-
label='test-label'
44-
/>
45-
)
46-
47-
await expect(component).toHaveAttribute('href', '/test/uri');
48-
});
49-
})
50-
51-
test.describe('functionality', () => {
52-
test('calls onClick when clicked', async ({mount}) => {
53-
let clicked = false;
54-
const component = await mount(
55-
<TextLinkForTest
56-
href='/test/uri'
57-
label='test-label'
58-
onClick={() => {
59-
clicked = true;
60-
}}
28+
{...props}
6129
/>,
6230
);
63-
await component.click();
6431

65-
expect(clicked).toBeTruthy();
32+
const screenshot = await component.screenshot();
33+
expect(screenshot).toMatchSnapshot();
6634
});
35+
});
36+
});
6737

68-
test('calls onClick when Enter pressed', async ({ mount }) => {
69-
let clicked = false;
70-
const component = await mount(
71-
<TextLinkForTest
72-
href='/test/uri'
73-
label='test-label'
74-
onClick={() => {
75-
clicked = true;
76-
}}
77-
/>,
78-
);
79-
await component.press('Enter');
80-
81-
expect(clicked).toBeTruthy();
82-
});
83-
})
84-
});
38+
test.describe('non-visual', () => {
39+
test('href', async ({ mount }) => {
40+
const component = await mount(
41+
<TextLinkForTest
42+
href="/test/uri"
43+
label="test-label"
44+
/>,
45+
);
46+
47+
await expect(component).toHaveAttribute('href', '/test/uri');
48+
});
49+
});
50+
51+
test.describe('functionality', () => {
52+
test('calls onClick when clicked', async ({ mount }) => {
53+
let clicked = false;
54+
const component = await mount(
55+
<TextLinkForTest
56+
href="/test/uri"
57+
label="test-label"
58+
onClick={() => {
59+
clicked = true;
60+
}}
61+
/>,
62+
);
63+
await component.click();
64+
65+
expect(clicked).toBeTruthy();
66+
});
67+
68+
test('calls onClick when Enter pressed', async ({ mount }) => {
69+
let clicked = false;
70+
const component = await mount(
71+
<TextLinkForTest
72+
href="/test/uri"
73+
label="test-label"
74+
onClick={() => {
75+
clicked = true;
76+
}}
77+
/>,
78+
);
79+
80+
await component.press('Enter');
81+
expect(clicked).toBeTruthy();
82+
});
83+
});
84+
});

src/components/TextLink/__tests__/TextLink.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ type TextLinkForTestProps = AnchorHTMLAttributes<HTMLAnchorElement>;
88
export const TextLinkForTest = ({
99
...props
1010
}: TextLinkForTestProps) => (
11-
<TextLink {...props}/>
12-
);
11+
<TextLink {...props} />
12+
);

0 commit comments

Comments
 (0)