mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
test(ct): solid callbacks (#16837)
This commit is contained in:
parent
3b1af7d75d
commit
a0f19a4f2d
@ -1,6 +1,7 @@
|
|||||||
type ButtonProps = {
|
type ButtonProps = {
|
||||||
title: string;
|
title: string;
|
||||||
|
onClick?(props: string): void;
|
||||||
}
|
}
|
||||||
export default function Button(props: ButtonProps) {
|
export default function Button(props: ButtonProps) {
|
||||||
return <button>{props.title}</button>
|
return <button onClick={() => props.onClick?.('hello')}>{props.title}</button>
|
||||||
}
|
}
|
||||||
|
@ -7,3 +7,12 @@ test('props should work', async ({ mount }) => {
|
|||||||
const component = await mount(<Button title="Submit" />);
|
const component = await mount(<Button title="Submit" />);
|
||||||
await expect(component).toContainText('Submit');
|
await expect(component).toContainText('Submit');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('callback should work', async ({ mount }) => {
|
||||||
|
const messages: string[] = []
|
||||||
|
const component = await mount(<Button title="Submit" onClick={data => {
|
||||||
|
messages.push(data)
|
||||||
|
}}></Button>)
|
||||||
|
await component.click()
|
||||||
|
expect(messages).toEqual(['hello'])
|
||||||
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user