Skip to content

Commit

Permalink
test: test that the field can be cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
Devessier committed Dec 17, 2024
1 parent 33a3d21 commit 34e959b
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,28 @@ export const CanUseVariableAsObjectProperty: Story = {

await userEvent.type(editor, '": 2 }');

await waitFor(() => {
expect(args.onPersist).toHaveBeenCalledWith('{ "{{test}}": 2 }');
});
},
};

export const ClearField: Story = {
args: {
placeholder: 'Enter valid json',
defaultValue: '{ "a": 2 }',
},
play: async ({ canvasElement, args }) => {
const defaultValueStringLength = args.defaultValue!.length;

const editor = canvasElement.querySelector('.ProseMirror > p');
expect(editor).toBeVisible();

await Promise.all([
userEvent.type(editor, `{Backspace>${defaultValueStringLength}}`),

waitFor(() => {
expect(args.onPersist).toHaveBeenCalledWith('{ "{{test}}": 2 }');
expect(args.onPersist).toHaveBeenCalledWith(null);
}),
]);
},
Expand Down

0 comments on commit 34e959b

Please sign in to comment.