Skip to content

Commit

Permalink
Switch loadedNotes test to listen for the event rather than using s…
Browse files Browse the repository at this point in the history
…etTimeout

Much better to just listen for the thing we are trying to test,
than to wait 50ms and see whether the thing had been called.
I think this was causing the test to fail occasinally on CI.  (It passes locally.)
  • Loading branch information
bhousel committed Aug 28, 2024
1 parent 7970b66 commit a2f42a5
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions test/browser/services/OsmService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,14 +722,12 @@ describe('OsmService', () => {
headers: { 'Content-Type': 'text/xml' }
});

_osm.on('loadedNotes', spy);
_osm.loadNotes({ /*no options*/ });

window.setTimeout(() => {
// was: calledOnce, now called multiple times as we fetch margin tiles
expect(spy.called).to.be.ok;
_osm.on('loadedNotes', () => {
expect(fetchMock.calls()).to.have.lengthOf.at.least(1);
done();
}, 50);
});

_osm.loadNotes({ /*no options*/ });
});
});

Expand Down

0 comments on commit a2f42a5

Please sign in to comment.