Skip to content

Commit

Permalink
fix: review
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB committed Nov 18, 2024
1 parent c2e263b commit 6ae2524
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe(`sbb-autocomplete-grid`, () => {
expect(input).to.have.attribute('aria-expanded', 'true');

// Simulate backdrop click
sendMouse({ type: 'click', position: [formField.offsetWidth + 25, 25] });
await sendMouse({ type: 'click', position: [formField.offsetWidth + 25, 25] });

await willCloseEventSpy.calledTimes(3);
expect(willCloseEventSpy.count).to.be.equal(3);
Expand Down
2 changes: 1 addition & 1 deletion src/elements/autocomplete/autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe(`sbb-autocomplete`, () => {
expect(input).to.have.attribute('aria-expanded', 'true');

// Simulate backdrop click
sendMouse({ type: 'click', position: [formField.offsetWidth + 25, 25] });
await sendMouse({ type: 'click', position: [formField.offsetWidth + 25, 25] });

await willCloseEventSpy.calledTimes(3);
expect(willCloseEventSpy.count).to.be.equal(3);
Expand Down
8 changes: 6 additions & 2 deletions src/elements/core/testing/event-spy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ export class EventSpy<T extends Event> {
}

public calledTimes(count: number, timeout = 1000): Promise<T> {
if (this.count >= count) {
if (this.count > count) {
return Promise.reject(
`Event has been emitted more than expected (expected ${count}, actual ${this.count}`,
);

Check warning on line 51 in src/elements/core/testing/event-spy.ts

View check run for this annotation

Codecov / codecov/patch

src/elements/core/testing/event-spy.ts#L49-L51

Added lines #L49 - L51 were not covered by tests
} else if (this.count === count) {
return Promise.resolve(this.events[count - 1]);
} else if (this._promiseEventMap.has(count)) {
return this._wrapPromiseWithTimeout(this._promiseEventMap.get(count)!, count, timeout);
return this._promiseEventMap.get(count)!.promise;

Check warning on line 55 in src/elements/core/testing/event-spy.ts

View check run for this annotation

Codecov / codecov/patch

src/elements/core/testing/event-spy.ts#L55

Added line #L55 was not covered by tests
} else {
let resolve: (value: T) => void;
let reject: (reason?: any) => void;
Expand Down

0 comments on commit 6ae2524

Please sign in to comment.