Skip to content

Commit

Permalink
test: refactor tests of AppIconButton
Browse files Browse the repository at this point in the history
Signed-off-by: Rong Sen Ng (motss) <[email protected]>
  • Loading branch information
motss committed Jan 6, 2024
1 parent 264612e commit 01ae9f1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 34 deletions.
16 changes: 10 additions & 6 deletions src/__tests__/icon-button/app-icon-button.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import '../../icon-button/app-icon-button';

import { expect, fixture, html } from '@open-wc/testing';
import { sendKeys } from '@web/test-runner-commands';
import { fixture, html } from '@open-wc/testing-helpers';
import { describe, expect, it } from 'vitest';

import type {AppIconButton } from '../../icon-button/app-icon-button';
import type { AppIconButton } from '../../icon-button/app-icon-button';
import { appIconButtonName } from '../../icon-button/constants';

describe(appIconButtonName, () => {
Expand All @@ -12,19 +12,23 @@ describe(appIconButtonName, () => {
<app-icon-button></app-icon-button>
`);

expect(await el.ripple).not.exist;
expect(await el.ripple).not.toBeInTheDocument();

el.focus();

/**
* NOTE(motss): `.click()` and `.focus()` does not render any ripple.
* So we need to actually focus with keypress or mouse click.
*
* fixme: use native browser keypress when vitest supports it.
*/
await sendKeys({ press: 'Enter' });
el.dispatchEvent(new KeyboardEvent('keypress', {
key: 'Enter',
}));

// Force layout
await el.layout();

expect(await el.ripple).exist;
expect(await el.ripple).toBeInTheDocument();
});
});
28 changes: 0 additions & 28 deletions src/__tests__/test-utils/it-each.ts

This file was deleted.

1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default defineConfig({
'**/*test*/helpers/to-resolved-date.test.ts',
'**/*test*/helpers/to-year-list.test.ts',
'**/*test*/helpers/warn-undefined-element.test.ts',
'**/*test*/icon-button/**.test.ts',
// '**/*test*/date-picker-input/**.test.ts',
],
clearMocks: true,
Expand Down

0 comments on commit 01ae9f1

Please sign in to comment.