Test that FeedbackButton returns early.

This commit is contained in:
Bauke 2022-03-18 00:03:46 +01:00
parent 594e06f0f5
commit 89bec5af88
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 27 additions and 2 deletions

View File

@ -11,7 +11,7 @@ test.before(() => {
}); });
test('FeedbackButton', async (t) => { test('FeedbackButton', async (t) => {
t.plan(5); t.plan(7);
const props: FeedbackButtonProps = { const props: FeedbackButtonProps = {
attributes: { attributes: {
@ -23,7 +23,32 @@ test('FeedbackButton', async (t) => {
timeout: 1000, timeout: 1000,
}; };
render(html`<${FeedbackButton} ...${props} />`, document); const noFeedbackProps: FeedbackButtonProps = {
...props,
attributes: {
id: 'no-feedback-button',
},
click(event) {
props.click(event);
return false;
},
};
render(
html`
<${FeedbackButton} ...${props} />
<${FeedbackButton} ...${noFeedbackProps} />
`,
document,
);
const noFeedbackButton = document.querySelector<HTMLButtonElement>(
'#no-feedback-button',
)!;
noFeedbackButton.click();
await sleep();
t.false(noFeedbackButton.outerHTML.includes(props.feedbackText));
const buttonElement = const buttonElement =
document.querySelector<HTMLButtonElement>('#feedback-button')!; document.querySelector<HTMLButtonElement>('#feedback-button')!;