Skip to content

Commit

Permalink
Fix for maplibre#3878 - address review comments (done -> async)
Browse files Browse the repository at this point in the history
  • Loading branch information
olsen232 committed May 7, 2024
1 parent 26c3e90 commit ea213f4
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions src/ui/camera.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ describe('#flyTo', () => {
camera.flyTo({center: [100, 0], bearing: 90, animate: true});
});

test('check elevation events freezeElevation=false', done => {
test('check elevation events freezeElevation=false', async() => {
const camera = createCamera();
const stub = jest.spyOn(browser, 'now');

Expand All @@ -1740,28 +1740,21 @@ describe('#flyTo', () => {

camera.setCenter([-10, 0]);

camera.on('moveend', () => {
await camera.once('moveend', () => {
expect(terrainCallbacks.prepare).toBe(1);
expect(terrainCallbacks.update).toBe(2);
expect(terrainCallbacks.finalize).toBe(0);
done();
});

stub.mockImplementation(() => 0);
camera.flyTo({center: [10, 0], duration: 20, freezeElevation: false});

setTimeout(() => {
stub.mockImplementation(() => 1);
camera.simulateFrame();

setTimeout(() => {
stub.mockImplementation(() => 20);
camera.simulateFrame();
}, 0);
}, 0);
stub.mockImplementation(() => 1);
camera.simulateFrame();
stub.mockImplementation(() => 20);
camera.simulateFrame();
});

test('check elevation events freezeElevation=true', done => {
test('check elevation events freezeElevation=true', async() => {
const camera = createCamera();
const stub = jest.spyOn(browser, 'now');

Expand All @@ -1773,25 +1766,18 @@ describe('#flyTo', () => {

camera.setCenter([-10, 0]);

camera.on('moveend', () => {
await camera.once('moveend', () => {
expect(terrainCallbacks.prepare).toBe(1);
expect(terrainCallbacks.update).toBe(0);
expect(terrainCallbacks.finalize).toBe(1);
done();
expect(terrainCallbacks.prepare).toBe(1);
});

stub.mockImplementation(() => 0);
camera.flyTo({center: [10, 0], duration: 20, freezeElevation: true});

setTimeout(() => {
stub.mockImplementation(() => 1);
camera.simulateFrame();

setTimeout(() => {
stub.mockImplementation(() => 20);
camera.simulateFrame();
}, 0);
}, 0);
stub.mockImplementation(() => 1);
camera.simulateFrame();
stub.mockImplementation(() => 20);
camera.simulateFrame();
});

test('check elevation callbacks', done => {
Expand Down

0 comments on commit ea213f4

Please sign in to comment.