Skip to content

Commit bf41e3a

Browse files
committed
test(mobile): read the scan call's this from the mock, not an alias
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jUw36sPe8KXr9ANYMv
1 parent cfa0fd1 commit bf41e3a

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

‎ui/packages/mobile/src/__tests__/nativeHost.test.tsx‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,12 @@ describe('typed call wrappers feature-detect and never throw', () => {
226226

227227
it('scan resolves "ok" with the decoded text, forwards the formats, and keeps the bridge as `this`', async () => {
228228
const bridge = fakeBridge();
229-
let self: unknown;
230-
bridge.scan = vi.fn(async function (this: unknown) {
231-
self = this;
232-
return 'ASSET-0042';
233-
});
229+
const scan = vi.fn(async () => 'ASSET-0042');
230+
bridge.scan = scan;
234231
install(bridge);
235232
await expect(nativeScan({ formats: ['qr', 'ean13'] })).resolves.toEqual({ status: 'ok', value: 'ASSET-0042' });
236-
expect(bridge.scan).toHaveBeenCalledWith({ formats: ['qr', 'ean13'] });
237-
expect(self).toBe(bridge);
233+
expect(scan).toHaveBeenCalledWith({ formats: ['qr', 'ean13'] });
234+
expect(scan.mock.contexts[0]).toBe(bridge);
238235
});
239236

240237
it('scan resolves "ok" with null when the user closes the scanner', async () => {

0 commit comments

Comments
 (0)