Skip to content

Commit

Permalink
fix test case to use usb package
Browse files Browse the repository at this point in the history
  • Loading branch information
koji committed Jan 17, 2024
1 parent e153d72 commit 4f39838
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app-shell/src/system-info/__tests__/usb-devices.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import execa from 'execa'
import { usb, webusb } from 'usb'
import { webusb } from 'usb'

import * as Fixtures from '@opentrons/app/src/redux/system-info/__fixtures__'
import { createUsbDeviceMonitor, getWindowsDriverVersion } from '../usb-devices'
Expand Down Expand Up @@ -37,17 +37,17 @@ describe('app-shell::system-info::usb-devices', () => {
it('can notify when devices are added', () => {
const onDeviceAdd = jest.fn()
createUsbDeviceMonitor({ onDeviceAdd })

usb.on('attach', mockDevice => onDeviceAdd)
webusb.removeEventListener('connect', onDeviceAdd(mockDevice))
webusb.addEventListener('connect', onDeviceAdd(mockDevice))

expect(onDeviceAdd).toHaveBeenCalledWith(mockDevice)
})

it('can notify when devices are removed', () => {
const onDeviceRemove = jest.fn()
createUsbDeviceMonitor({ onDeviceRemove })

usb.on('detach', mockDevice => onDeviceRemove)
webusb.removeEventListener('disconnect', onDeviceRemove(mockDevice))
webusb.addEventListener('disconnect', onDeviceRemove(mockDevice))

expect(onDeviceRemove).toHaveBeenCalledWith(mockDevice)
})
Expand Down

0 comments on commit 4f39838

Please sign in to comment.