Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cristinecula committed Nov 18, 2024
1 parent 4b11e45 commit d9eca0e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/use-autocomplete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ describe('use-autocomplete', () => {
.textProperty=${'text'}
/>
`);

expect(result.current.query).to.equal('It');
expect(await result.current.items$).to.be.empty;
expect(result.current.items).to.be.empty;
});

it('focus', async () => {
Expand All @@ -38,10 +39,10 @@ describe('use-autocomplete', () => {
/>`,
);

expect(await result.current.items$).to.be.empty;
expect(result.current.items).to.be.empty;
result.current.onFocus({ currentTarget: { matches: () => true } });
await nextFrame();
expect(await result.current.items$).not.to.be.empty;
expect(result.current.items).not.to.be.empty;
expect(onFocus).to.have.been.calledOnceWith(true);
});

Expand Down Expand Up @@ -128,16 +129,16 @@ describe('use-autocomplete', () => {
result = await fixture(html`
<use-autocomplete
.source=${source}
.text=${'La'}
.text=${'1'}
.textProperty=${'text'}
.external=${true}
/>
`);
expect(result.current.query).to.equal('La');
expect(result.current.query).to.equal('1');
result.current.onFocus({ currentTarget: { matches: () => true } });
await nextFrame();

expect(await result.current.items$).to.have.lengthOf(2);
expect(result.current.items).to.have.lengthOf(1);
});

it('valueProperty', async () => {
Expand All @@ -158,6 +159,6 @@ describe('use-autocomplete', () => {
result.current.onFocus({ currentTarget: { matches: () => true } });
await nextFrame();

expect(await result.current.items$).to.be.deep.equal(source);
expect(result.current.items).to.be.deep.equal(source);
});
});

0 comments on commit d9eca0e

Please sign in to comment.