Skip to content

Commit

Permalink
test: fix failing test on input's clear racing condition
Browse files Browse the repository at this point in the history
  • Loading branch information
sun-mota committed Nov 15, 2024
1 parent dbd89a6 commit 11ac6c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/input/src/base-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ export default class BaseInput extends LitElement {
*/
handleClickClear() {
this.inputElement.value = "";
this.value = undefined;
this.value = "";
this.labelElement.classList.remove('inputElement-label--sticky');
this.focus();
this.validation.validate(this);
Expand Down
6 changes: 4 additions & 2 deletions components/input/test/auro-input.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fixture, html, expect, elementUpdated, oneEvent } from '@open-wc/testing';
import { fixture, html, expect, elementUpdated, oneEvent, nextFrame } from '@open-wc/testing';
import '../src/index.js';

describe('auro-input', () => {
Expand Down Expand Up @@ -68,7 +68,8 @@ describe('auro-input', () => {

const clearButton = el.shadowRoot.querySelector('.clearBtn');
clearButton.click();
expect(el.value).to.be.undefined;
await elementUpdated();
expect(el.value).to.equal('');
});

it('flips hide-password bit', async () => {
Expand Down Expand Up @@ -183,6 +184,7 @@ describe('auro-input', () => {
input.blur();

await elementUpdated(el);
await nextFrame();

expect(el.hasAttribute('validity')).to.be.true;
});
Expand Down

0 comments on commit 11ac6c1

Please sign in to comment.