Skip to content

Commit

Permalink
test: reinstate test for optional dependency canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
foxxyz committed Jun 9, 2024
1 parent 2e3699e commit 23519a3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 24 deletions.
4 changes: 0 additions & 4 deletions test/device-ct.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@ describe('Drawing (Callback API)', () => {
await delay(10)
expect(sender).toHaveBeenCalledTimes(1)
})
// TODO: mock canvas
// it('informs the user if the canvas library is not installed', () => {
// expect(() => device.drawKey(6, () => {})).toThrow(/using callbacks requires the `canvas` library/i)
// })
})
describe('Drawing (Buffer API)', () => {
beforeEach(() => {
Expand Down
5 changes: 0 additions & 5 deletions test/device-live-s.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ describe('Drawing (Callback API)', () => {
await delay(10)
expect(sender).toHaveBeenCalledTimes(1)
})
// TODO: mock canvas lib
// it('informs the user if the canvas library is not installed', () => {
// jest.mock('canvas', () => {})
// expect(() => device.drawKey(6, () => {})).toThrow(/using callbacks requires the `canvas` library/i)
// })
})
describe('Drawing (Buffer API)', () => {
beforeEach(() => {
Expand Down
5 changes: 0 additions & 5 deletions test/device-live.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@ describe('Drawing (Callback API)', () => {
await delay(10)
expect(sender).toHaveBeenCalledTimes(1)
})
// TODO: Mock canvas lib
// it('informs the user if the canvas library is not installed', () => {
// jest.mock('canvas', () => {})
// expect(() => device.drawKey(6, () => {})).toThrow(/using callbacks requires the `canvas` library/i)
// })
})
describe('Drawing (Buffer API)', () => {
beforeEach(() => {
Expand Down
5 changes: 0 additions & 5 deletions test/device-razer-x.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ describe('Drawing (Callback API)', () => {
await delay(10)
expect(sender).toHaveBeenCalledTimes(1)
})
// TODO: Mock canvas lib
// it('informs the user if the canvas library is not installed', () => {
// jest.mock('canvas', () => {})
// expect(() => device.drawKey(6, () => {})).toThrow(/using callbacks requires the `canvas` library/i)
// })
})
describe('Drawing (Buffer API)', () => {
beforeEach(() => {
Expand Down
5 changes: 0 additions & 5 deletions test/device-razer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@ describe('Drawing (Callback API)', () => {
await delay(10)
expect(sender).toHaveBeenCalledTimes(1)
})
// TODO: Mock canvas lib
// it('informs the user if the canvas library is not installed', () => {
// jest.mock('canvas', () => {})
// expect(() => device.drawKey(6, () => {})).toThrow(/using callbacks requires the `canvas` library/i)
// })
})
describe('Drawing (Buffer API)', () => {
beforeEach(() => {
Expand Down
14 changes: 14 additions & 0 deletions test/optional-deps.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { jest } from '@jest/globals'
jest.unstable_mockModule('canvas', () => ({}))
const { LoupedeckLiveS } = await import('../index.js')

let device
describe('Optional Dependencies', () => {
beforeEach(() => {
device = new LoupedeckLiveS({ autoConnect: false })
device.connection = { send: () => {}, isReady: () => true }
})
it('informs the user if the canvas library is not installed', () => {
expect(() => device.drawKey(6, () => {})).toThrow(/using callbacks requires the `canvas` library/i)
})
})

0 comments on commit 23519a3

Please sign in to comment.