Skip to content

Commit

Permalink
enable --no-isolate to speed up unit tests
Browse files Browse the repository at this point in the history
This required fixing deferred code that was running after the unit test had unmounted
  • Loading branch information
k-yle committed Sep 9, 2024
1 parent 4f239ac commit 156f6a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/renderer/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,9 @@ export function rendererMap(context) {


function redraw(difference, extent) {
// in unit tests, we need to abort if the test has already completed
if (typeof window === 'undefined') return;

if (surface.empty() || !_redrawEnabled) return;

// If we are in the middle of a zoom/pan, we can't do differenced redraws.
Expand Down
3 changes: 3 additions & 0 deletions modules/util/session_mutex.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export function utilSessionMutex(name) {
var intervalID;

function renew() {
// in unit tests, we need to abort if the test has already completed
if (typeof window === 'undefined') return;

var expires = new Date();
expires.setSeconds(expires.getSeconds() + 5);
document.cookie = name + '=1; expires=' + expires.toUTCString() + '; sameSite=strict';
Expand Down
3 changes: 3 additions & 0 deletions test/spec/services/panoramax.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ describe('iD.servicePanoramax', function() {
panoramax = iD.services.panoramax;
panoramax.reset();
fetchMock.reset();

// never resolve
fetchMock.mock(/api\.panoramax\.xyz/, new Promise(() => {}));
});

afterEach(function() {
Expand Down

0 comments on commit 156f6a8

Please sign in to comment.