mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Add test for suffix hydration (#4982)
This commit is contained in:
parent
50a397c4ba
commit
9683ae64ff
3 changed files with 25 additions and 0 deletions
|
@ -0,0 +1,10 @@
|
|||
import React, { useState } from 'react';
|
||||
|
||||
export default function () {
|
||||
const [open, setOpen] = useState(false);
|
||||
return (
|
||||
<button id="suffix" onClick={() => setOpen(!open)}>
|
||||
suffix toggle {open.toString()}
|
||||
</button>
|
||||
);
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
import Counter from '../components/Counter.jsx';
|
||||
import ReactComponent from '../components/JSXComponent.jsx';
|
||||
import Suffix from '../components/Suffix.react';
|
||||
|
||||
const someProps = {
|
||||
count: 0,
|
||||
|
@ -33,5 +34,7 @@ const someProps = {
|
|||
</Counter>
|
||||
|
||||
<ReactComponent id="client-only" client:only="react" />
|
||||
|
||||
<Suffix client:load />
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { expect } from '@playwright/test';
|
||||
import { prepareTestFactory } from './shared-component-tests.js';
|
||||
|
||||
const { test, createTests } = prepareTestFactory({ root: './fixtures/react-component/' });
|
||||
|
@ -30,3 +31,14 @@ test.describe('React components in MDX files', () => {
|
|||
pageSourceFilePath: './src/pages/mdx.mdx',
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('dev', () => {
|
||||
test('Loads .react suffix', async ({ page, astro }) => {
|
||||
await page.goto(astro.resolveUrl('/'));
|
||||
|
||||
const suffix = page.locator('#suffix');
|
||||
expect(await suffix.textContent()).toBe('suffix toggle false');
|
||||
await suffix.click();
|
||||
expect(await suffix.textContent()).toBe('suffix toggle true');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue