mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 17:22:19 +00:00
Check point coordinates without coercion and drop tests main already covers
This commit is contained in:
1 parent
ed586a40a1
commit
93f848d8b1
2 files changed
+9
-49
No files matched your search
@@ -9,30 +9,21 @@ function fixture() {
|
||||
{ camera: { id: 'east', lat: 40, lon: -100 } },
|
||||
];
|
||||
const state = { _records: records };
|
||||
const eye = { pose: { lat: 40, lon: -101 } };
|
||||
const parts = {
|
||||
model: {
|
||||
eyePose: () => eye.pose,
|
||||
eyePose: () => ({ lat: 40, lon: -101 }),
|
||||
haversineKm(lat1, lon1, lat2, lon2) {
|
||||
return Math.hypot(lat1 - lat2, lon1 - lon2);
|
||||
},
|
||||
},
|
||||
};
|
||||
const selected = [];
|
||||
parts.selection = {
|
||||
setActiveCamera(cameraId) {
|
||||
selected.push(cameraId);
|
||||
state._activeCameraId = cameraId;
|
||||
state._openingCameraProvisional = false;
|
||||
},
|
||||
};
|
||||
const navigation = createNavigation({
|
||||
state,
|
||||
services: {},
|
||||
parts,
|
||||
source: {},
|
||||
});
|
||||
return { state, eye, navigation, selected };
|
||||
return { navigation };
|
||||
}
|
||||
|
||||
test('nearest camera can be resolved from an explicit WGS84 target', () => {
|
||||
@@ -50,6 +41,7 @@ test('invalid target coordinates fail closed', () => {
|
||||
const { navigation } = fixture();
|
||||
for (const [lat, lon] of [
|
||||
[NaN, 0],
|
||||
[null, 0],
|
||||
[0, Infinity],
|
||||
[90.00001, 0],
|
||||
[-90.00001, 0],
|
||||
@@ -59,31 +51,3 @@ test('invalid target coordinates fail closed', () => {
|
||||
assert.equal(navigation.nearestCameraIdToPoint(lat, lon), null);
|
||||
}
|
||||
});
|
||||
|
||||
test('opening camera keeps viewer-nearest and first-record fallback', () => {
|
||||
const { state, eye, navigation } = fixture();
|
||||
assert.equal(navigation.openingCameraId(), 'east');
|
||||
eye.pose = null;
|
||||
assert.equal(navigation.openingCameraId(), 'west');
|
||||
state._records = [];
|
||||
assert.equal(navigation.openingCameraId(), null);
|
||||
});
|
||||
|
||||
test('settled move retargets only a provisional opening camera', () => {
|
||||
const { state, navigation, selected } = fixture();
|
||||
state._enabled = true;
|
||||
state._openingCameraProvisional = true;
|
||||
state._activeCameraId = 'west';
|
||||
assert.equal(navigation.reopenNearestCamera(), true);
|
||||
assert.deepEqual(selected, ['east']);
|
||||
assert.equal(state._activeCameraId, 'east');
|
||||
assert.equal(state._openingCameraProvisional, true);
|
||||
assert.equal(navigation.reopenNearestCamera(), false);
|
||||
state._activeCameraId = 'west';
|
||||
state._openingCameraProvisional = false;
|
||||
assert.equal(navigation.reopenNearestCamera(), false);
|
||||
state._openingCameraProvisional = true;
|
||||
state._enabled = false;
|
||||
assert.equal(navigation.reopenNearestCamera(), false);
|
||||
assert.deepEqual(selected, ['east']);
|
||||
});
|
||||
Reference in new issue
Block a user