mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(data): the selection dispatcher treats an unowned pick as empty space
Task 10a moves flights onto the dispatcher; its old handler deselected on a pick nobody owns (an unclaimed entity), and only another layer's pick was not empty space. The dispatcher now does the same (after drill-through owners had their chance), and selectionDispatcherFor(engine) gives the application one dispatcher per engine. Tests for both.
This commit is contained in:
1 parent
9f1a0611fa
commit
8e702f0c3b
2 files changed
+56
-3
No files matched your search
@@ -1,7 +1,10 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createFakeEngine } from '../globe/testing/fakeEngine.js';
|
||||
import { createSelectionDispatcher } from './selectionDispatcher.js';
|
||||
import {
|
||||
createSelectionDispatcher,
|
||||
selectionDispatcherFor,
|
||||
} from './selectionDispatcher.js';
|
||||
import {
|
||||
isOwnedByOtherLayer,
|
||||
registerPickOwner,
|
||||
@@ -95,6 +98,22 @@ test("another layer's pick is not empty space, owned through the shared registry
|
||||
}
|
||||
});
|
||||
|
||||
test('a pick no layer owns is empty space, as for the old handlers', () => {
|
||||
const { dispatcher, click } = setup({ 10: [{ id: 'unclaimed-entity' }] });
|
||||
const flights = recorder();
|
||||
dispatcher.register('flights', {
|
||||
owns: (id) => id === 'x',
|
||||
...flights.handlers,
|
||||
});
|
||||
click(10);
|
||||
click(10, { ms: 900 });
|
||||
assert.deepEqual(
|
||||
flights.calls,
|
||||
[['empty', 0]],
|
||||
'a long press does not deselect',
|
||||
);
|
||||
});
|
||||
|
||||
test('trails do not take clicks: the object under a trail is selected', () => {
|
||||
const { dispatcher, click } = setup({
|
||||
10: [{ id: 'trail-ae01ce', owner: 'flights-trail' }, { id: 'ae01ce' }],
|
||||
@@ -173,3 +192,16 @@ test('unregister and destroy remove the subscriptions', () => {
|
||||
assert.equal(isOwnedByOtherLayer('other', 'a'), false);
|
||||
assert.ok(engine.fake.callsOf('input.on').length >= 1);
|
||||
});
|
||||
|
||||
test('the application has one dispatcher per engine', () => {
|
||||
const engine = createFakeEngine();
|
||||
const other = createFakeEngine();
|
||||
assert.equal(selectionDispatcherFor(engine), selectionDispatcherFor(engine));
|
||||
assert.notEqual(
|
||||
selectionDispatcherFor(engine),
|
||||
selectionDispatcherFor(other),
|
||||
);
|
||||
assert.equal(selectionDispatcherFor(null), null);
|
||||
selectionDispatcherFor(engine).destroy();
|
||||
selectionDispatcherFor(other).destroy();
|
||||
});
|
||||
Reference in new issue
Block a user