|
|
@ -10,6 +10,7 @@ import { |
|
|
|
import type { DatasetChanges } from "@ldo/rdf-utils"; |
|
|
|
import type { DatasetChanges } from "@ldo/rdf-utils"; |
|
|
|
import type { ReadSuccess } from "../../src/results/success/ReadSuccess.js"; |
|
|
|
import type { ReadSuccess } from "../../src/results/success/ReadSuccess.js"; |
|
|
|
import type { UpdateSuccess } from "../../src/results/success/UpdateSuccess.js"; |
|
|
|
import type { UpdateSuccess } from "../../src/results/success/UpdateSuccess.js"; |
|
|
|
|
|
|
|
import { vi } from "vitest"; |
|
|
|
|
|
|
|
|
|
|
|
export class MockResource |
|
|
|
export class MockResource |
|
|
|
extends (EventEmitter as new () => ResourceEventEmitter) |
|
|
|
extends (EventEmitter as new () => ResourceEventEmitter) |
|
|
@ -26,34 +27,32 @@ export class MockResource |
|
|
|
this.status = new Unfetched(this); |
|
|
|
this.status = new Unfetched(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
isLoading = jest.fn<boolean, []>(); |
|
|
|
isLoading = vi.fn<() => boolean>(); |
|
|
|
isFetched = jest.fn<boolean, []>(); |
|
|
|
isFetched = vi.fn<() => boolean>(); |
|
|
|
isUnfetched = jest.fn<boolean, []>(); |
|
|
|
isUnfetched = vi.fn<() => boolean>(); |
|
|
|
isDoingInitialFetch = jest.fn<boolean, []>(); |
|
|
|
isDoingInitialFetch = vi.fn<() => boolean>(); |
|
|
|
isPresent = jest.fn<boolean | undefined, []>(); |
|
|
|
isPresent = vi.fn<() => boolean | undefined>(); |
|
|
|
isAbsent = jest.fn<boolean | undefined, []>(); |
|
|
|
isAbsent = vi.fn<() => boolean | undefined>(); |
|
|
|
isSubscribedToNotifications = jest.fn<boolean, []>(); |
|
|
|
isSubscribedToNotifications = vi.fn<() => boolean>(); |
|
|
|
|
|
|
|
|
|
|
|
read = jest.fn<Promise<ReadSuccess<any> | ResourceError<any>>, []>(); |
|
|
|
read = vi.fn<() => Promise<ReadSuccess<any> | ResourceError<any>>>(); |
|
|
|
readIfUnfetched = jest.fn< |
|
|
|
readIfUnfetched = |
|
|
|
Promise<ReadSuccess<any> | ResourceError<any>>, |
|
|
|
vi.fn<() => Promise<ReadSuccess<any> | ResourceError<any>>>(); |
|
|
|
[] |
|
|
|
update = |
|
|
|
>(); |
|
|
|
vi.fn< |
|
|
|
update = jest.fn< |
|
|
|
( |
|
|
|
Promise<UpdateSuccess<any> | ResourceError<any>>, |
|
|
|
changes: DatasetChanges, |
|
|
|
[DatasetChanges] |
|
|
|
) => Promise<UpdateSuccess<any> | ResourceError<any>> |
|
|
|
>(); |
|
|
|
>(); |
|
|
|
|
|
|
|
|
|
|
|
subscribeToNotifications = jest.fn< |
|
|
|
subscribeToNotifications = |
|
|
|
Promise<string>, |
|
|
|
vi.fn< |
|
|
|
[ |
|
|
|
(options?: { |
|
|
|
{ |
|
|
|
|
|
|
|
onNotification: (message: any) => void; |
|
|
|
onNotification: (message: any) => void; |
|
|
|
onNotificationError: (err: Error) => void; |
|
|
|
onNotificationError: (err: Error) => void; |
|
|
|
}?, |
|
|
|
}) => Promise<string> |
|
|
|
] |
|
|
|
|
|
|
|
>(); |
|
|
|
>(); |
|
|
|
|
|
|
|
|
|
|
|
unsubscribeFromNotifications = jest.fn<Promise<void>, [string]>(); |
|
|
|
unsubscribeFromNotifications = vi.fn<(id: string) => Promise<void>>(); |
|
|
|
unsubscribeFromAllNotifications = jest.fn<Promise<void>, []>(); |
|
|
|
unsubscribeFromAllNotifications = vi.fn<() => Promise<void>>(); |
|
|
|
} |
|
|
|
} |
|
|
|