Skip to content

Commit

Permalink
chore: fix test: mock @parcel/watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Oct 12, 2023
1 parent 2ca1c0a commit d7d63b2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/internal-tests/src/__mocks__/@parcel/watcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
console.log('aaaaaaaaaaaaa')

export async function getEventsSince(_dir: FilePath, _snapshot: FilePath, _opts?: Options): Promise<Event[]> {
// not implemented
return []
}
export async function subscribe(_dir: FilePath, _fn: SubscribeCallback, _opts?: Options): Promise<AsyncSubscription> {
return new AsyncSubscription()
}
export async function unsubscribe(_dir: FilePath, _fn: SubscribeCallback, _opts?: Options): Promise<void> {
// not implemented
}
export async function writeSnapshot(_dir: FilePath, _snapshot: FilePath, _opts?: Options): Promise<FilePath> {
// 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<void> {}
}
1 change: 1 addition & 0 deletions tests/internal-tests/src/__tests__/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/internal-tests/src/__tests__/issues.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tests/internal-tests/src/__tests__/quantel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d7d63b2

Please sign in to comment.