Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Apr 20, 2022
1 parent 2f95eb6 commit 772166c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/core/src/__tests__/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ describe('Xencelabs Quick Keys', () => {
await expect(async () => quickKeys.setKeyText(8, 'abc')).rejects.toThrow()
})

// eslint-disable-next-line jest/no-commented-out-tests
// test('forwards error events from the device', () => {
// const errorSpy = jest.fn()
// quickKeys.on('error', errorSpy)
Expand Down
6 changes: 6 additions & 0 deletions packages/node/src/__mocks__/hid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@ export class DummyHID extends EventEmitter implements HID {
public setNonBlocking(_no_block: boolean): void {
throw new Error('Method not implemented.')
}
public sendFeatureReport(_data: number[] | Buffer): number {
throw new Error('Method not implemented.')
}
public getFeatureReport(_report_id: number, _report_length: number): number[] {
throw new Error('Method not implemented.')
}
}
5 changes: 2 additions & 3 deletions packages/node/src/__tests__/device.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/* eslint-disable jest/no-commented-out-tests */
import { mocked } from 'ts-jest/utils'

import { DummyHID } from '../__mocks__/hid'
import { DEVICE_INTERFACE } from '../manager'

jest.mock('node-hid')
import { devices, HID } from 'node-hid'
// Forcing path to be string, as there are multiple constructor options, we require the string one
mocked(HID).mockImplementation((path: any) => new DummyHID(path))
jest.mocked(HID).mockImplementation((path: any) => new DummyHID(path))

// Must be required after we register a mock for `node-hid`.
import { PRODUCT_IDS_WIRED, PRODUCT_IDS_WIRELESS, VENDOR_ID } from '@xencelabs-quick-keys/core'

describe('Xence Quick Keys', () => {
function mockDevicesImplementation() {
mocked(devices).mockImplementation(() => [
jest.mocked(devices).mockImplementation(() => [
...[...PRODUCT_IDS_WIRED, ...PRODUCT_IDS_WIRELESS].map((id) => ({
productId: id,
vendorId: VENDOR_ID,
Expand Down

0 comments on commit 772166c

Please sign in to comment.