Baptiste Devessier
2025-04-04 11:20:57 +02:00
committed by GitHub
parent bb40bc9929
commit 9353e777ea
10 changed files with 91 additions and 3 deletions

View File

@ -1,7 +1,9 @@
import { Meta, StoryObj } from '@storybook/react';
import {
expect,
fn,
userEvent,
waitFor,
waitForElementToBeRemoved,
within,
} from '@storybook/test';
@ -482,3 +484,32 @@ export const RedHighlighting: Story = {
expect(ageElement).toBeVisible();
},
};
export const CopyJsonNodeValue: Story = {
args: {
value: {
name: 'John Doe',
age: 30,
},
onNodeValueClick: fn(),
},
play: async ({ canvasElement, args }) => {
const canvas = within(canvasElement);
const nameValue = await canvas.findByText('John Doe');
await userEvent.click(nameValue);
await waitFor(() => {
expect(args.onNodeValueClick).toHaveBeenCalledWith('John Doe');
});
const ageValue = await canvas.findByText('30');
await userEvent.click(ageValue);
await waitFor(() => {
expect(args.onNodeValueClick).toHaveBeenCalledWith('30');
});
},
};