Skip to content

Commit

Permalink
testing ☢️
Browse files Browse the repository at this point in the history
  • Loading branch information
Molly Lloyd committed Mar 22, 2017
1 parent 814c084 commit 6aa3c54
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/unit/ui/camera.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ test('camera', (t) => {
t.end();
});

t.test('emits pitch events, preserving eventData', (t)=>{
let started, pitched, ended;
const eventData = { data: 'ok'};

camera
.on('pitchstart', (d) => { started = d.data; })
.on('pitch', (d) => { pitched = d.data; })
.on('pitchend', (d) => { ended = d.data; });

camera.jumpTo({pitch: 10}, eventData);
t.equal(started, 'ok');
t.equal(pitched, 'ok');
t.equal(ended, 'ok');
t.end();
})

t.test('cancels in-progress easing', (t) => {
camera.panTo([3, 4]);
t.ok(camera.isEasing());
Expand Down Expand Up @@ -861,14 +877,16 @@ test('camera', (t) => {
//As such; it deserves a separate test case. This test case flies the map from A to A.
const fromTo = { center: [100, 0] };
const camera = createCamera(fromTo);
let movestarted, moved, rotated, pitched, zoomstarted, zoomed, zoomended;
let movestarted, moved, rotated, pitched, pitchstarted, pitchended, zoomstarted, zoomed, zoomended;
const eventData = { data: 'ok' };

camera
.on('movestart', (d) => { movestarted = d.data; })
.on('move', (d) => { moved = d.data; })
.on('rotate', (d) => { rotated = d.data; })
.on('pitch', (d) => { pitched = d.data; })
.on('pitchstart', (d) => { pitchstarted = d.data; })
.on('pitchend', (d) => { pitchended = d.data; })
.on('zoomstart', (d) => { zoomstarted = d.data; })
.on('zoom', (d) => { zoomed = d.data; })
.on('zoomend', (d) => { zoomended = d.data; })
Expand All @@ -884,6 +902,8 @@ test('camera', (t) => {
t.equal(zoomended, undefined);
t.equal(rotated, undefined);
t.equal(pitched, undefined);
t.equal(pitchstarted, undefined);
t.equal(pitchended, undefined);
t.equal(d.data, 'ok');
t.end();
});
Expand Down

0 comments on commit 6aa3c54

Please sign in to comment.