Skip to content

Commit

Permalink
test: use platform instead of jest.done (#4794)
Browse files Browse the repository at this point in the history
  • Loading branch information
birkskyum authored Oct 2, 2024
1 parent 0ba4781 commit 01e57c7
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions src/ui/camera.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2659,7 +2659,7 @@ describe('#easeTo globe projection', () => {
camera.easeTo({center: [100, 0], duration: 0});
});

test('pans eastward across the antimeridian', done => {
test('pans eastward across the antimeridian', () => new Promise<void>(done => {
const camera = createCameraGlobe();
const stub = jest.spyOn(browser, 'now');

Expand Down Expand Up @@ -2689,19 +2689,19 @@ describe('#easeTo globe projection', () => {
camera.simulateFrame();
}, 0);
}, 0);
});
}));

test('does pan eastward across the antimeridian on a renderWorldCopies: false map if globe is enabled', done => {
test('does pan eastward across the antimeridian on a renderWorldCopies: false map if globe is enabled', () => new Promise<void>(done => {
const camera = createCameraGlobe({renderWorldCopies: false, zoom: 2});
camera.setCenter([170, 0]);
camera.on('moveend', () => {
expect(camera.getCenter().lng).toBeCloseTo(-150, 0);
done();
});
camera.easeTo({center: [210, 0], duration: 0});
});
}));

test('pans westward across the antimeridian', done => {
test('pans westward across the antimeridian', () => new Promise<void>(done => {
const camera = createCameraGlobe();
const stub = jest.spyOn(browser, 'now');

Expand Down Expand Up @@ -2731,17 +2731,17 @@ describe('#easeTo globe projection', () => {
camera.simulateFrame();
}, 0);
}, 0);
});
}));

test('does pan westward across the antimeridian on a renderWorldCopies: false map if globe is enabled', done => {
test('does pan westward across the antimeridian on a renderWorldCopies: false map if globe is enabled', () => new Promise<void>(done => {
const camera = createCameraGlobe({renderWorldCopies: false, zoom: 2});
camera.setCenter([-170, 0]);
camera.on('moveend', () => {
expect(camera.getCenter().lng).toBeCloseTo(150, 0);
done();
});
camera.easeTo({center: [-210, 0], duration: 0});
});
}));
});
});

Expand Down Expand Up @@ -2800,7 +2800,7 @@ describe('#flyTo globe projection', () => {
expect(camera.getZoom()).toBe(2);
});

test('Zoom out from the same position to the same position with animation', done => {
test('Zoom out from the same position to the same position with animation', () => new Promise<void>(done => {
const pos = {lng: 0, lat: 0};
const camera = createCameraGlobe({zoom: 20, center: pos});
const stub = jest.spyOn(browser, 'now');
Expand All @@ -2816,7 +2816,7 @@ describe('#flyTo globe projection', () => {

stub.mockImplementation(() => 3);
camera.simulateFrame();
});
}));

test('rotates to specified bearing', () => {
const camera = createCameraGlobe();
Expand Down Expand Up @@ -2947,7 +2947,7 @@ describe('#flyTo globe projection', () => {
eventData);
});

test('for short flights, emits (solely) move events, preserving eventData', done => {
test('for short flights, emits (solely) move events, preserving eventData', () => new Promise<void>(done => {
//As I type this, the code path for guiding super-short flights is (and will probably remain) different.
//As such; it deserves a separate test case. This test case flies the map from A to A.
const camera = createCameraGlobe({center: [100, 0]});
Expand Down Expand Up @@ -3003,9 +3003,9 @@ describe('#flyTo globe projection', () => {
camera.simulateFrame();
}, 0);
}, 0);
});
}));

test('ascends', done => {
test('ascends', () => new Promise<void>(done => {
const camera = createCameraGlobe();
camera.setZoom(18);
let ascended;
Expand Down Expand Up @@ -3036,9 +3036,9 @@ describe('#flyTo globe projection', () => {
camera.simulateFrame();
}, 0);
}, 0);
});
}));

test('pans eastward across the prime meridian', done => {
test('pans eastward across the prime meridian', () => new Promise<void>(done => {
const camera = createCameraGlobe();
const stub = jest.spyOn(browser, 'now');

Expand Down Expand Up @@ -3068,9 +3068,9 @@ describe('#flyTo globe projection', () => {
camera.simulateFrame();
}, 0);
}, 0);
});
}));

test('pans westward across the prime meridian', done => {
test('pans westward across the prime meridian', () => new Promise<void>(done => {
const camera = createCameraGlobe();
const stub = jest.spyOn(browser, 'now');

Expand Down Expand Up @@ -3100,9 +3100,9 @@ describe('#flyTo globe projection', () => {
camera.simulateFrame();
}, 0);
}, 0);
});
}));

test('pans eastward across the antimeridian', done => {
test('pans eastward across the antimeridian', () => new Promise<void>(done => {
const camera = createCameraGlobe();
const stub = jest.spyOn(browser, 'now');

Expand Down Expand Up @@ -3132,9 +3132,9 @@ describe('#flyTo globe projection', () => {
camera.simulateFrame();
}, 0);
}, 0);
});
}));

test('pans westward across the antimeridian', done => {
test('pans westward across the antimeridian', () => new Promise<void>(done => {
const camera = createCameraGlobe();
const stub = jest.spyOn(browser, 'now');

Expand Down Expand Up @@ -3164,9 +3164,9 @@ describe('#flyTo globe projection', () => {
camera.simulateFrame();
}, 0);
}, 0);
});
}));

test('pans eastward across the antimeridian even if renderWorldCopies: false', done => {
test('pans eastward across the antimeridian even if renderWorldCopies: false', () => new Promise<void>(done => {
const camera = createCameraGlobe({renderWorldCopies: false});
const stub = jest.spyOn(browser, 'now');

Expand Down Expand Up @@ -3196,9 +3196,9 @@ describe('#flyTo globe projection', () => {
camera.simulateFrame();
}, 0);
}, 0);
});
}));

test('pans westward across the antimeridian even if renderWorldCopies: false', done => {
test('pans westward across the antimeridian even if renderWorldCopies: false', () => new Promise<void>(done => {
const camera = createCameraGlobe({renderWorldCopies: false});
const stub = jest.spyOn(browser, 'now');

Expand Down Expand Up @@ -3228,9 +3228,9 @@ describe('#flyTo globe projection', () => {
camera.simulateFrame();
}, 0);
}, 0);
});
}));

test('jumps back to world 0 when crossing the antimeridian', done => {
test('jumps back to world 0 when crossing the antimeridian', () => new Promise<void>(done => {
const camera = createCameraGlobe();
const stub = jest.spyOn(browser, 'now');

Expand Down Expand Up @@ -3259,9 +3259,9 @@ describe('#flyTo globe projection', () => {
camera.simulateFrame();
}, 0);
}, 0);
});
}));

test('peaks at the specified zoom level', done => {
test('peaks at the specified zoom level', () => new Promise<void>(done => {
const camera = createCameraGlobe({zoom: 20});
const stub = jest.spyOn(browser, 'now');

Expand All @@ -3272,7 +3272,7 @@ describe('#flyTo globe projection', () => {
camera.on('zoom', () => {
const zoom = camera.getZoom();
if (zoom < 1) {
fail(`${zoom} should be >= ${minZoom} during flyTo`);
throw new Error(`${zoom} should be >= ${minZoom} during flyTo`);
}

leastZoom = Math.min(leastZoom, zoom);
Expand All @@ -3299,9 +3299,9 @@ describe('#flyTo globe projection', () => {
camera.simulateFrame();
}, 0);
}, 0);
});
}));

test('respects transform\'s maxZoom', done => {
test('respects transform\'s maxZoom', () => new Promise<void>(done => {
const camera = createCameraGlobe();
camera.transform.setMinZoom(2);
camera.transform.setMaxZoom(10);
Expand All @@ -3322,9 +3322,9 @@ describe('#flyTo globe projection', () => {
stub.mockImplementation(() => 10);
camera.simulateFrame();
}, 0);
});
}));

test('respects transform\'s minZoom', done => {
test('respects transform\'s minZoom', () => new Promise<void>(done => {
const transform = createCameraGlobe().transform;
transform.setMinZoom(2);
transform.setMaxZoom(10);
Expand All @@ -3351,9 +3351,9 @@ describe('#flyTo globe projection', () => {
stub.mockImplementation(() => 10);
camera.simulateFrame();
}, 0);
});
}));

test('resets duration to 0 if it exceeds maxDuration', done => {
test('resets duration to 0 if it exceeds maxDuration', () => new Promise<void>(done => {
let startTime, endTime, timeDiff;
const camera = createCameraGlobe({center: [37.63454, 55.75868], zoom: 18});

Expand All @@ -3367,7 +3367,7 @@ describe('#flyTo globe projection', () => {
});

camera.flyTo({center: [-122.3998631, 37.7884307], maxDuration: 100});
});
}));

// No terrain/elevation tests for globe, as terrain isn't supported (yet?)
});
Expand Down

0 comments on commit 01e57c7

Please sign in to comment.