From c9389f1ac795e21befda58d40d0e4b35f2ba5a14 Mon Sep 17 00:00:00 2001 From: Johan Nyman Date: Thu, 12 Oct 2023 12:21:02 +0200 Subject: [PATCH] chore: fix tests --- .../src/__mocks__/@parcel/watcher.ts | 33 +++++++++++++++++++ .../src/__tests__/basic.spec.ts | 1 + .../src/__tests__/issues.spec.ts | 1 + .../src/__tests__/quantel.spec.ts | 1 + 4 files changed, 36 insertions(+) create mode 100644 tests/internal-tests/src/__mocks__/@parcel/watcher.ts diff --git a/tests/internal-tests/src/__mocks__/@parcel/watcher.ts b/tests/internal-tests/src/__mocks__/@parcel/watcher.ts new file mode 100644 index 00000000..11131650 --- /dev/null +++ b/tests/internal-tests/src/__mocks__/@parcel/watcher.ts @@ -0,0 +1,33 @@ +export async function getEventsSince(_dir: FilePath, _snapshot: FilePath, _opts?: Options): Promise { + // not implemented + return [] +} +export async function subscribe(_dir: FilePath, _fn: SubscribeCallback, _opts?: Options): Promise { + return new AsyncSubscription() +} +export async function unsubscribe(_dir: FilePath, _fn: SubscribeCallback, _opts?: Options): Promise { + // not implemented +} +export async function writeSnapshot(_dir: FilePath, _snapshot: FilePath, _opts?: Options): Promise { + // not implemented + return './mock-snapshot' +} + +type FilePath = string +type GlobPattern = string +type BackendType = 'fs-events' | 'watchman' | 'inotify' | 'windows' | 'brute-force' +type EventType = 'create' | 'update' | 'delete' +interface Options { + ignore?: (FilePath | GlobPattern)[] + backend?: BackendType +} +type SubscribeCallback = (err: Error | null, events: Event[]) => unknown +interface Event { + path: FilePath + type: EventType +} +class AsyncSubscription { + async unsubscribe(): Promise { + // not implemented + } +} diff --git a/tests/internal-tests/src/__tests__/basic.spec.ts b/tests/internal-tests/src/__tests__/basic.spec.ts index 2a408b76..8d3cacaf 100644 --- a/tests/internal-tests/src/__tests__/basic.spec.ts +++ b/tests/internal-tests/src/__tests__/basic.spec.ts @@ -22,6 +22,7 @@ jest.mock('mkdirp') jest.mock('child_process') jest.mock('windows-network-drive') jest.mock('tv-automation-quantel-gateway-client') +jest.mock('@parcel/watcher') const fs = fsOrg as any as typeof fsMockType const WND = WNDOrg as any as typeof WNDType diff --git a/tests/internal-tests/src/__tests__/issues.spec.ts b/tests/internal-tests/src/__tests__/issues.spec.ts index 53f69965..369dc554 100644 --- a/tests/internal-tests/src/__tests__/issues.spec.ts +++ b/tests/internal-tests/src/__tests__/issues.spec.ts @@ -13,6 +13,7 @@ jest.mock('mkdirp') jest.mock('child_process') jest.mock('windows-network-drive') jest.mock('tv-automation-quantel-gateway-client') +jest.mock('@parcel/watcher') const fs = fsOrg as any as typeof fsMockType diff --git a/tests/internal-tests/src/__tests__/quantel.spec.ts b/tests/internal-tests/src/__tests__/quantel.spec.ts index 479cc750..9c500864 100644 --- a/tests/internal-tests/src/__tests__/quantel.spec.ts +++ b/tests/internal-tests/src/__tests__/quantel.spec.ts @@ -8,6 +8,7 @@ import { waitUntil } from './lib/lib' import { getQuantelSource, getQuantelTarget } from './lib/containers' jest.mock('child_process') jest.mock('tv-automation-quantel-gateway-client') +jest.mock('@parcel/watcher') const QGatewayClient = QGatewayClientOrg as any as typeof QGatewayClientType