Skip to content

Commit b8f30a0

Browse files
test(core): regression test for mjolnir requireFailure wiring
Construct a Deck and verify pinch, pan, and click each have the expected blocking recognizer in their requireFail array. Catches the `requestFailure` typo class of bug without depending on TypeScript flagging it through mjolnir's union type.
1 parent 7501827 commit b8f30a0

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

test/modules/core/lib/deck.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,40 @@ test('Deck#constructor', async () => {
116116
console.log('Deck constructor did not throw');
117117
});
118118

119+
test('Deck wires mjolnir requireFailure between recognizers', async () => {
120+
// Regression guard: deck.gl previously emitted `requestFailure` instead of
121+
// `requireFailure`, which mjolnir silently dropped — so pinch/pan/click no
122+
// longer waited for their blocking recognizer to fail.
123+
await new Promise<void>((resolve, reject) => {
124+
const deck = new Deck({
125+
device,
126+
width: 1,
127+
height: 1,
128+
viewState: {longitude: 0, latitude: 0, zoom: 0},
129+
layers: [],
130+
controller: true,
131+
onLoad: () => {
132+
try {
133+
const recognizers = (deck as any).eventManager?.manager?.recognizers ?? [];
134+
const requiredFailures = (event: string): string[] =>
135+
(recognizers.find(r => r.options.event === event)?.requireFail ?? []).map(
136+
(r: any) => r.options.event
137+
);
138+
139+
expect(requiredFailures('pinch'), 'pinch waits for multipan').toContain('multipan');
140+
expect(requiredFailures('pan'), 'pan waits for multipan').toContain('multipan');
141+
expect(requiredFailures('click'), 'click waits for dblclick').toContain('dblclick');
142+
143+
deck.finalize();
144+
resolve();
145+
} catch (error) {
146+
reject(error);
147+
}
148+
}
149+
});
150+
});
151+
});
152+
119153
test('Deck#abort', async () => {
120154
const deck = new Deck({
121155
device,

0 commit comments

Comments
 (0)