Skip to content

Commit

Permalink
Fix ContactView tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed Oct 2, 2023
1 parent efd6f60 commit 33f1073
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/www/views/contact_view/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,27 @@ describe('ContactView', () => {
expect(supportForm).not.toBeNull();
});

it('emits contact success event on completion of support form', async () => {
const listener = oneEvent(el, 'SupportContacted');
it('emits success event on completion of support form', async () => {
const listener = oneEvent(el, 'success');

const supportForm: SupportForm = el.shadowRoot!.querySelector('support-form')!;
supportForm.valid = true;
supportForm.dispatchEvent(new CustomEvent('submit'));

const {detail} = await listener;
expect(detail).toBeTrue();
expect(detail).toBeNull();
});

it('emits contact failure event when feedback reporting fails', async () => {
const listener = oneEvent(el, 'SupportContacted');
it('emits failure event when feedback reporting fails', async () => {
const listener = oneEvent(el, 'error');
mockErrorReporter.report.and.throwError('fail');

const supportForm: SupportForm = el.shadowRoot!.querySelector('support-form')!;
supportForm.valid = true;
supportForm.dispatchEvent(new CustomEvent('submit'));

const {detail} = await listener;
expect(detail).toBeFalse();
expect(detail).toBeNull();
});

it('shows default contact view on cancellation of support form', async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/www/views/contact_view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ export class ContactView extends LitElement {
} catch (e) {
console.error(`Failed to send feedback report: ${e.message}`);
this.isFormSubmitting = false;
this.dispatchEvent(new CustomEvent('error', {bubbles: true, composed: true}));
this.dispatchEvent(new CustomEvent('error'));
return;
}

this.isFormSubmitting = false;
this.dispatchEvent(new CustomEvent('success', {bubbles: true, composed: true}));
this.reset();
this.dispatchEvent(new CustomEvent('success'));
}

private get renderIntroTemplate(): TemplateResult {
Expand Down

0 comments on commit 33f1073

Please sign in to comment.