use-scan-detection
Advanced tools
Comparing version 0.1.2 to 0.1.3
{ | ||
"name": "use-scan-detection", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "A react hook for detecting barcode scanner input.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -141,2 +141,37 @@ import { renderHook, act } from '@testing-library/react-hooks' | ||
}) | ||
it('should respect preventDefault', () => { | ||
const config = { | ||
onComplete: jest.fn(), | ||
preventDefault: true | ||
} | ||
renderHook(() => useScanDetection(config)) | ||
const event = events[0] | ||
const mockPreventDefault = jest.spyOn(event, "preventDefault") | ||
document.dispatchEvent(event) | ||
expect(mockPreventDefault) | ||
.toHaveBeenCalled() | ||
}) | ||
it('should respect stopPropagation', () => { | ||
const config = { | ||
onComplete: jest.fn(), | ||
stopPropagation: true | ||
} | ||
renderHook(() => useScanDetection(config)) | ||
const event = events[0] | ||
const mockStopPropagation = jest.spyOn(event, "stopPropagation") | ||
document.dispatchEvent(event) | ||
expect(mockStopPropagation) | ||
.toHaveBeenCalled() | ||
}) | ||
}) |
17239
360