Skip to content

Commit

Permalink
Cover globe projection for isMoving and isRotating (#11817)
Browse files Browse the repository at this point in the history
  • Loading branch information
akoylasar authored Apr 25, 2022
1 parent 8826bc0 commit a5ee3f6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 26 deletions.
34 changes: 21 additions & 13 deletions test/unit/ui/map/isMoving.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import Map from '../../../../src/ui/map.js';
import * as DOM from '../../../../src/util/dom.js';
import simulate from '../../../util/simulate_interaction.js';

function createMap(t) {
function createMap(t, proj = 'mercator') {
t.stub(Map.prototype, '_detectMissingCSS');
t.stub(Map.prototype, '_authenticate');
return new Map({container: DOM.create('div', '', window.document.body)});
const map = new Map({container: DOM.create('div', '', window.document.body)});
map.setProjection(proj);
return map;
}

// MouseEvent.buttons
Expand All @@ -21,20 +23,26 @@ test('Map#isMoving returns false by default', (t) => {
t.end();
});

test('Map#isMoving returns true during a camera zoom animation', (t) => {
const map = createMap(t);
test('Map#isMoving with various projections', (t) => {
const projections = ['globe', 'mercator'];
for (const proj of projections) {
test('Map#isMoving returns true during a camera zoom animation', (t) => {
const map = createMap(t, proj);

map.on('zoomstart', () => {
t.equal(map.isMoving(), true);
});
map.on('zoomstart', () => {
t.equal(map.isMoving(), true);
});

map.on('zoomend', () => {
t.equal(map.isMoving(), false);
map.remove();
t.end();
});
map.on('zoomend', () => {
t.equal(map.isMoving(), false);
map.remove();
t.end();
});

map.zoomTo(5, {duration: 0});
map.zoomTo(5, {duration: 0});
});
}
t.end();
});

test('Map#isMoving returns true when drag panning', (t) => {
Expand Down
34 changes: 21 additions & 13 deletions test/unit/ui/map/isRotating.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import * as DOM from '../../../../src/util/dom.js';
import simulate from '../../../util/simulate_interaction.js';
import browser from '../../../../src/util/browser.js';

function createMap(t) {
function createMap(t, proj = 'mercator') {
t.stub(Map.prototype, '_detectMissingCSS');
t.stub(Map.prototype, '_authenticate');
return new Map({container: DOM.create('div', '', window.document.body)});
const map = new Map({container: DOM.create('div', '', window.document.body)});
map.setProjection(proj);
return map;
}

test('Map#isRotating returns false by default', (t) => {
Expand All @@ -18,20 +20,26 @@ test('Map#isRotating returns false by default', (t) => {
t.end();
});

test('Map#isRotating returns true during a camera rotate animation', (t) => {
const map = createMap(t);
test('#MapisRotating with various projections', (t) => {
const projections = ['globe', 'mercator'];
for (const proj of projections) {
test('Map#isRotating returns true during a camera rotate animation', (t) => {
const map = createMap(t, proj);

map.on('rotatestart', () => {
t.equal(map.isRotating(), true);
});
map.on('rotatestart', () => {
t.equal(map.isRotating(), true);
});

map.on('rotateend', () => {
t.equal(map.isRotating(), false);
map.remove();
t.end();
});
map.on('rotateend', () => {
t.equal(map.isRotating(), false);
map.remove();
t.end();
});

map.rotateTo(5, {duration: 0});
map.rotateTo(5, {duration: 0});
});
}
t.end();
});

test('Map#isRotating returns true when drag rotating', (t) => {
Expand Down

0 comments on commit a5ee3f6

Please sign in to comment.