@fedify/testing 1.8.1-pr.283.1138

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright 2024–2025 Hong Minhee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # @fedify/testing
2
+
3
+ Testing utilities for Fedify applications.
4
+
5
+ This package provides mock implementations of the `Federation` and `Context`
6
+ interfaces to facilitate unit testing of federated applications built with
7
+ Fedify.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ deno add @fedify/testing
13
+ ```
14
+
15
+ ```bash
16
+ npm install @fedify/testing
17
+ ```
18
+
19
+ ```bash
20
+ pnpm add @fedify/testing
21
+ ```
22
+
23
+ ```bash
24
+ yarn add @fedify/testing
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### MockFederation
30
+
31
+ The `MockFederation` class provides a mock implementation of the `Federation`
32
+ interface for unit testing:
33
+
34
+ ```typescript
35
+ import { MockFederation } from "@fedify/testing";
36
+ import { Create } from "@fedify/fedify/vocab";
37
+
38
+ // Create a mock federation
39
+ const federation = new MockFederation<{ userId: string }>();
40
+
41
+ // Set up inbox listeners
42
+ federation
43
+ .setInboxListeners("/users/{identifier}/inbox")
44
+ .on(Create, async (ctx, activity) => {
45
+ console.log("Received:", activity);
46
+ });
47
+
48
+ // Simulate receiving an activity
49
+ await federation.receiveActivity(createActivity);
50
+
51
+ // Check sent activities
52
+ const sent = federation.sentActivities;
53
+ console.log(sent[0].activity);
54
+ ```
55
+
56
+ ### MockContext
57
+
58
+ The `MockContext` class provides a mock implementation of the `Context`
59
+ interface:
60
+
61
+ ```typescript
62
+ import { MockContext } from "@fedify/testing";
63
+
64
+ // Create a mock context
65
+ const context = new MockContext({
66
+ url: new URL("https://example.com"),
67
+ data: { userId: "test-user" },
68
+ federation: mockFederation
69
+ });
70
+
71
+ // Send an activity
72
+ await context.sendActivity(
73
+ { identifier: "alice" },
74
+ recipient,
75
+ activity
76
+ );
77
+
78
+ // Check sent activities
79
+ const sent = context.getSentActivities();
80
+ console.log(sent[0].activity);
81
+ ```
82
+
83
+ ### Helper Functions
84
+
85
+ The package also exports helper functions for creating various context types:
86
+
87
+ - `createContext()` - Creates a basic context
88
+ - `createRequestContext()` - Creates a request context
89
+ - `createInboxContext()` - Creates an inbox context
90
+
91
+ ## Features
92
+
93
+ - Track sent activities with metadata
94
+ - Simulate activity reception
95
+ - Configure custom URI templates
96
+ - Test queue-based activity processing
97
+ - Mock document loaders and context loaders
98
+
99
+ ## License
100
+
101
+ MIT
package/context.ts ADDED
@@ -0,0 +1,154 @@
1
+ import { trace } from "@opentelemetry/api";
2
+ import type {
3
+ Context,
4
+ InboxContext,
5
+ RequestContext,
6
+ } from "@fedify/fedify/federation";
7
+ import type { Federation } from "@fedify/fedify/federation";
8
+ import { RouterError } from "@fedify/fedify/federation";
9
+ import {
10
+ lookupObject as globalLookupObject,
11
+ traverseCollection as globalTraverseCollection,
12
+ } from "@fedify/fedify/vocab";
13
+ import { lookupWebFinger as globalLookupWebFinger } from "@fedify/fedify/webfinger";
14
+ import { mockDocumentLoader } from "./docloader.ts";
15
+
16
+ // NOTE: Copied from @fedify/fedify/testing/context.ts
17
+
18
+ export function createContext<TContextData>(
19
+ values: Partial<Context<TContextData>> & {
20
+ url?: URL;
21
+ data: TContextData;
22
+ federation: Federation<TContextData>;
23
+ },
24
+ ): Context<TContextData> {
25
+ const {
26
+ federation,
27
+ url = new URL("http://example.com/"),
28
+ canonicalOrigin,
29
+ data,
30
+ documentLoader,
31
+ contextLoader,
32
+ tracerProvider,
33
+ clone,
34
+ getNodeInfoUri,
35
+ getActorUri,
36
+ getObjectUri,
37
+ getOutboxUri,
38
+ getInboxUri,
39
+ getFollowingUri,
40
+ getFollowersUri,
41
+ getLikedUri,
42
+ getFeaturedUri,
43
+ getFeaturedTagsUri,
44
+ parseUri,
45
+ getActorKeyPairs,
46
+ getDocumentLoader,
47
+ lookupObject,
48
+ traverseCollection,
49
+ lookupNodeInfo,
50
+ lookupWebFinger,
51
+ sendActivity,
52
+ routeActivity,
53
+ } = values;
54
+ function throwRouteError(): URL {
55
+ throw new RouterError("Not implemented");
56
+ }
57
+ return {
58
+ federation,
59
+ data,
60
+ origin: url.origin,
61
+ canonicalOrigin: canonicalOrigin ?? url.origin,
62
+ host: url.host,
63
+ hostname: url.hostname,
64
+ documentLoader: documentLoader ?? mockDocumentLoader,
65
+ contextLoader: contextLoader ?? mockDocumentLoader,
66
+ tracerProvider: tracerProvider ?? trace.getTracerProvider(),
67
+ clone: clone ?? ((data) => createContext({ ...values, data })),
68
+ getNodeInfoUri: getNodeInfoUri ?? throwRouteError,
69
+ getActorUri: getActorUri ?? throwRouteError,
70
+ getObjectUri: getObjectUri ?? throwRouteError,
71
+ getOutboxUri: getOutboxUri ?? throwRouteError,
72
+ getInboxUri: getInboxUri ?? throwRouteError,
73
+ getFollowingUri: getFollowingUri ?? throwRouteError,
74
+ getFollowersUri: getFollowersUri ?? throwRouteError,
75
+ getLikedUri: getLikedUri ?? throwRouteError,
76
+ getFeaturedUri: getFeaturedUri ?? throwRouteError,
77
+ getFeaturedTagsUri: getFeaturedTagsUri ?? throwRouteError,
78
+ parseUri: parseUri ?? ((_uri) => {
79
+ throw new Error("Not implemented");
80
+ }),
81
+ getDocumentLoader: getDocumentLoader ?? ((_params) => {
82
+ throw new Error("Not implemented");
83
+ }),
84
+ getActorKeyPairs: getActorKeyPairs ?? ((_handle) => Promise.resolve([])),
85
+ lookupObject: lookupObject ?? ((uri, options = {}) => {
86
+ return globalLookupObject(uri, {
87
+ documentLoader: options.documentLoader ?? documentLoader ??
88
+ mockDocumentLoader,
89
+ contextLoader: options.contextLoader ?? contextLoader ??
90
+ mockDocumentLoader,
91
+ });
92
+ }),
93
+ traverseCollection: traverseCollection ?? ((collection, options = {}) => {
94
+ return globalTraverseCollection(collection, {
95
+ documentLoader: options.documentLoader ?? documentLoader ??
96
+ mockDocumentLoader,
97
+ contextLoader: options.contextLoader ?? contextLoader ??
98
+ mockDocumentLoader,
99
+ });
100
+ }),
101
+ lookupNodeInfo: lookupNodeInfo ?? ((_params) => {
102
+ throw new Error("Not implemented");
103
+ }),
104
+ lookupWebFinger: lookupWebFinger ?? ((resource, options = {}) => {
105
+ return globalLookupWebFinger(resource, options);
106
+ }),
107
+ sendActivity: sendActivity ?? ((_params) => {
108
+ throw new Error("Not implemented");
109
+ }),
110
+ routeActivity: routeActivity ?? ((_params) => {
111
+ throw new Error("Not implemented");
112
+ }),
113
+ };
114
+ }
115
+
116
+ export function createRequestContext<TContextData>(
117
+ args: Partial<RequestContext<TContextData>> & {
118
+ url: URL;
119
+ data: TContextData;
120
+ federation: Federation<TContextData>;
121
+ },
122
+ ): RequestContext<TContextData> {
123
+ return {
124
+ ...createContext(args),
125
+ clone: args.clone ?? ((data) => createRequestContext({ ...args, data })),
126
+ request: args.request ?? new Request(args.url),
127
+ url: args.url,
128
+ getActor: args.getActor ?? (() => Promise.resolve(null)),
129
+ getObject: args.getObject ?? (() => Promise.resolve(null)),
130
+ getSignedKey: args.getSignedKey ?? (() => Promise.resolve(null)),
131
+ getSignedKeyOwner: args.getSignedKeyOwner ?? (() => Promise.resolve(null)),
132
+ sendActivity: args.sendActivity ?? ((_params) => {
133
+ throw new Error("Not implemented");
134
+ }),
135
+ };
136
+ }
137
+
138
+ export function createInboxContext<TContextData>(
139
+ args: Partial<InboxContext<TContextData>> & {
140
+ url?: URL;
141
+ data: TContextData;
142
+ recipient?: string | null;
143
+ federation: Federation<TContextData>;
144
+ },
145
+ ): InboxContext<TContextData> {
146
+ return {
147
+ ...createContext(args),
148
+ clone: args.clone ?? ((data) => createInboxContext({ ...args, data })),
149
+ recipient: args.recipient ?? null,
150
+ forwardActivity: args.forwardActivity ?? ((_params) => {
151
+ throw new Error("Not implemented");
152
+ }),
153
+ };
154
+ }
package/deno.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@fedify/testing",
3
+ "version": "1.8.1-pr.283.1138+8009e193",
4
+ "license": "MIT",
5
+ "exports": {
6
+ ".": "./mod.ts"
7
+ },
8
+ "imports": {
9
+ "@opentelemetry/api": "npm:@opentelemetry/api@^1.9.0"
10
+ },
11
+ "exclude": [
12
+ ".github",
13
+ "node_modules",
14
+ "npm",
15
+ "pnpm-lock.yaml"
16
+ ],
17
+ "tasks": {
18
+ "build": "pnpm build",
19
+ "check": "deno fmt --check && deno lint && deno check mod.ts",
20
+ "test": "deno test --allow-read --allow-net",
21
+ "test:node": {
22
+ "dependencies": [
23
+ "build"
24
+ ],
25
+ "command": "node --experimental-transform-types --test"
26
+ },
27
+ "test:bun": {
28
+ "dependencies": [
29
+ "build"
30
+ ],
31
+ "command": "bun test --timeout 15000"
32
+ },
33
+ "test-all": {
34
+ "dependencies": [
35
+ "test",
36
+ "test:node",
37
+ "test:bun"
38
+ ]
39
+ }
40
+ }
41
+ }
package/dist/mod.d.ts ADDED
@@ -0,0 +1,274 @@
1
+ import { TracerProvider } from "@opentelemetry/api";
2
+ import { ActorCallbackSetters, ActorDispatcher, ActorKeyPair, CollectionCallbackSetters, CollectionDispatcher, Context, Federation, FederationFetchOptions, FederationStartQueueOptions, InboxListenerSetters, Message, NodeInfoDispatcher, ObjectCallbackSetters, ObjectDispatcher, ParseUriResult, RequestContext, RouteActivityOptions, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair } from "@fedify/fedify/federation";
3
+ import { Activity, Actor, Collection, Hashtag, LookupObjectOptions, Object as Object$1, Recipient, TraverseCollectionOptions } from "@fedify/fedify/vocab";
4
+ import { ResourceDescriptor } from "@fedify/fedify/webfinger";
5
+ import { JsonValue, NodeInfo } from "@fedify/fedify/nodeinfo";
6
+ import { DocumentLoader } from "@fedify/fedify/runtime";
7
+
8
+ //#region mock.d.ts
9
+
10
+ /**
11
+ * Represents a sent activity with metadata about how it was sent.
12
+ * @since 1.8.0
13
+ */
14
+ interface SentActivity {
15
+ /** Whether the activity was queued or sent immediately. */
16
+ queued: boolean;
17
+ /** Which queue was used (if queued). */
18
+ queue?: "inbox" | "outbox" | "fanout";
19
+ /** The activity that was sent. */
20
+ activity: Activity;
21
+ /** The order in which the activity was sent (auto-incrementing counter). */
22
+ sentOrder: number;
23
+ }
24
+ /**
25
+ * A mock implementation of the {@link Federation} interface for unit testing.
26
+ * This class provides a way to test Fedify applications without needing
27
+ * a real federation setup.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * import { Create } from "@fedify/fedify/vocab";
32
+ * import { MockFederation } from "@fedify/testing";
33
+ *
34
+ * // Create a mock federation with contextData
35
+ * const federation = new MockFederation<{ userId: string }>({
36
+ * contextData: { userId: "test-user" }
37
+ * });
38
+ *
39
+ * // Set up inbox listeners
40
+ * federation
41
+ * .setInboxListeners("/users/{identifier}/inbox")
42
+ * .on(Create, async (ctx, activity) => {
43
+ * console.log("Received:", activity);
44
+ * });
45
+ *
46
+ * // Simulate receiving an activity
47
+ * const createActivity = new Create({
48
+ * id: new URL("https://example.com/create/1"),
49
+ * actor: new URL("https://example.com/users/alice")
50
+ * });
51
+ * await federation.receiveActivity(createActivity);
52
+ * ```
53
+ *
54
+ * @typeParam TContextData The context data to pass to the {@link Context}.
55
+ * @since 1.8.0
56
+ */
57
+ declare class MockFederation<TContextData> implements Federation<TContextData> {
58
+ private options;
59
+ sentActivities: SentActivity[];
60
+ queueStarted: boolean;
61
+ private activeQueues;
62
+ sentCounter: number;
63
+ private nodeInfoDispatcher?;
64
+ private actorDispatchers;
65
+ actorPath?: string;
66
+ inboxPath?: string;
67
+ outboxPath?: string;
68
+ followingPath?: string;
69
+ followersPath?: string;
70
+ likedPath?: string;
71
+ featuredPath?: string;
72
+ featuredTagsPath?: string;
73
+ nodeInfoPath?: string;
74
+ sharedInboxPath?: string;
75
+ objectPaths: Map<string, string>;
76
+ private objectDispatchers;
77
+ private inboxDispatcher?;
78
+ private outboxDispatcher?;
79
+ private followingDispatcher?;
80
+ private followersDispatcher?;
81
+ private likedDispatcher?;
82
+ private featuredDispatcher?;
83
+ private featuredTagsDispatcher?;
84
+ private inboxListeners;
85
+ private contextData?;
86
+ private receivedActivities;
87
+ constructor(options?: {
88
+ contextData?: TContextData;
89
+ origin?: string;
90
+ tracerProvider?: TracerProvider;
91
+ });
92
+ setNodeInfoDispatcher(path: string, dispatcher: NodeInfoDispatcher<TContextData>): void;
93
+ setActorDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: ActorDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
94
+ setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: (new (...args: any[]) => TObject) & {
95
+ typeId: URL;
96
+ }, path: string, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
97
+ setInboxDispatcher(_path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
98
+ setOutboxDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
99
+ setFollowingDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Actor | URL, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
100
+ setFollowersDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Recipient, Context<TContextData>, TContextData, URL>): CollectionCallbackSetters<Context<TContextData>, TContextData, URL>;
101
+ setLikedDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Object$1 | URL, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
102
+ setFeaturedDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Object$1, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
103
+ setFeaturedTagsDispatcher(path: `${string}{identifier}${string}` | `${string}{handle}${string}`, dispatcher: CollectionDispatcher<Hashtag, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
104
+ setInboxListeners(inboxPath: `${string}{identifier}${string}` | `${string}{handle}${string}`, sharedInboxPath?: string): InboxListenerSetters<TContextData>;
105
+ startQueue(contextData: TContextData, options?: FederationStartQueueOptions): Promise<void>;
106
+ processQueuedTask(contextData: TContextData, _message: Message): Promise<void>;
107
+ createContext(baseUrl: URL, contextData: TContextData): Context<TContextData>;
108
+ createContext(request: Request, contextData: TContextData): RequestContext<TContextData>;
109
+ fetch(request: Request, options: FederationFetchOptions<TContextData>): Promise<Response>;
110
+ /**
111
+ * Simulates receiving an activity. This method is specific to the mock
112
+ * implementation and is used for testing purposes.
113
+ *
114
+ * @param activity The activity to receive.
115
+ * @returns A promise that resolves when the activity has been processed.
116
+ * @since 1.8.0
117
+ */
118
+ receiveActivity(activity: Activity): Promise<void>;
119
+ /**
120
+ * Clears all sent activities from the mock federation.
121
+ * This method is specific to the mock implementation and is used for
122
+ * testing purposes.
123
+ *
124
+ * @since 1.8.0
125
+ */
126
+ reset(): void;
127
+ }
128
+ /**
129
+ * A mock implementation of the {@link Context} interface for unit testing.
130
+ * This class provides a way to test Fedify applications without needing
131
+ * a real federation context.
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * import { Person, Create } from "@fedify/fedify/vocab";
136
+ * import { MockContext, MockFederation } from "@fedify/testing";
137
+ *
138
+ * // Create a mock context
139
+ * const mockFederation = new MockFederation<{ userId: string }>();
140
+ * const context = new MockContext({
141
+ * url: new URL("https://example.com"),
142
+ * data: { userId: "test-user" },
143
+ * federation: mockFederation
144
+ * });
145
+ *
146
+ * // Send an activity
147
+ * const recipient = new Person({ id: new URL("https://example.com/users/bob") });
148
+ * const activity = new Create({
149
+ * id: new URL("https://example.com/create/1"),
150
+ * actor: new URL("https://example.com/users/alice")
151
+ * });
152
+ * await context.sendActivity(
153
+ * { identifier: "alice" },
154
+ * recipient,
155
+ * activity
156
+ * );
157
+ *
158
+ * // Check sent activities
159
+ * const sent = context.getSentActivities();
160
+ * console.log(sent[0].activity);
161
+ * ```
162
+ *
163
+ * @typeParam TContextData The context data to pass to the {@link Context}.
164
+ * @since 1.8.0
165
+ */
166
+ declare class MockContext<TContextData> implements Context<TContextData> {
167
+ readonly origin: string;
168
+ readonly canonicalOrigin: string;
169
+ readonly host: string;
170
+ readonly hostname: string;
171
+ readonly data: TContextData;
172
+ readonly federation: Federation<TContextData>;
173
+ readonly documentLoader: DocumentLoader;
174
+ readonly contextLoader: DocumentLoader;
175
+ readonly tracerProvider: TracerProvider;
176
+ private sentActivities;
177
+ constructor(options: {
178
+ url?: URL;
179
+ data: TContextData;
180
+ federation: Federation<TContextData>;
181
+ documentLoader?: DocumentLoader;
182
+ contextLoader?: DocumentLoader;
183
+ tracerProvider?: TracerProvider;
184
+ });
185
+ clone(data: TContextData): Context<TContextData>;
186
+ getNodeInfoUri(): URL;
187
+ getActorUri(identifier: string): URL;
188
+ getObjectUri<TObject extends Object$1>(cls: (new (...args: any[]) => TObject) & {
189
+ typeId: URL;
190
+ }, values: Record<string, string>): URL;
191
+ getOutboxUri(identifier: string): URL;
192
+ getInboxUri(identifier: string): URL;
193
+ getInboxUri(): URL;
194
+ getFollowingUri(identifier: string): URL;
195
+ getFollowersUri(identifier: string): URL;
196
+ getLikedUri(identifier: string): URL;
197
+ getFeaturedUri(identifier: string): URL;
198
+ getFeaturedTagsUri(identifier: string): URL;
199
+ parseUri(uri: URL): ParseUriResult | null;
200
+ getActorKeyPairs(_identifier: string): Promise<ActorKeyPair[]>;
201
+ getDocumentLoader(params: {
202
+ handle: string;
203
+ } | {
204
+ identifier: string;
205
+ }): Promise<DocumentLoader>;
206
+ getDocumentLoader(params: {
207
+ keyId: URL;
208
+ privateKey: CryptoKey;
209
+ }): DocumentLoader;
210
+ lookupObject(_uri: URL | string, _options?: LookupObjectOptions): Promise<Object$1 | null>;
211
+ traverseCollection<TItem, TContext extends Context<TContextData>>(_collection: Collection | URL | null, _options?: TraverseCollectionOptions): AsyncIterable<TItem>;
212
+ lookupNodeInfo(url: URL | string, options?: {
213
+ parse?: "strict" | "best-effort";
214
+ } & any): Promise<NodeInfo | undefined>;
215
+ lookupNodeInfo(url: URL | string, options?: {
216
+ parse: "none";
217
+ } & any): Promise<JsonValue | undefined>;
218
+ lookupWebFinger(_resource: URL | `acct:${string}@${string}` | string, _options?: any): Promise<ResourceDescriptor | null>;
219
+ sendActivity(sender: SenderKeyPair | SenderKeyPair[] | {
220
+ identifier: string;
221
+ } | {
222
+ username: string;
223
+ } | {
224
+ handle: string;
225
+ }, recipients: Recipient | Recipient[], activity: Activity, options?: SendActivityOptions): Promise<void>;
226
+ sendActivity(sender: {
227
+ identifier: string;
228
+ } | {
229
+ username: string;
230
+ } | {
231
+ handle: string;
232
+ }, recipients: "followers", activity: Activity, options?: SendActivityOptionsForCollection): Promise<void>;
233
+ sendActivity(sender: SenderKeyPair | SenderKeyPair[] | {
234
+ identifier: string;
235
+ } | {
236
+ username: string;
237
+ } | {
238
+ handle: string;
239
+ }, recipients: Recipient | Recipient[], activity: Activity, options?: SendActivityOptions): Promise<void>;
240
+ sendActivity(sender: {
241
+ identifier: string;
242
+ } | {
243
+ username: string;
244
+ } | {
245
+ handle: string;
246
+ }, recipients: "followers", activity: Activity, options?: SendActivityOptionsForCollection): Promise<void>;
247
+ routeActivity(_recipient: string | null, _activity: Activity, _options?: RouteActivityOptions): Promise<boolean>;
248
+ /**
249
+ * Gets all activities that have been sent through this mock context.
250
+ * This method is specific to the mock implementation and is used for
251
+ * testing purposes.
252
+ *
253
+ * @returns An array of sent activity records.
254
+ */
255
+ getSentActivities(): Array<{
256
+ sender: SenderKeyPair | SenderKeyPair[] | {
257
+ identifier: string;
258
+ } | {
259
+ username: string;
260
+ } | {
261
+ handle: string;
262
+ };
263
+ recipients: Recipient | Recipient[] | "followers";
264
+ activity: Activity;
265
+ }>;
266
+ /**
267
+ * Clears all sent activities from the mock context.
268
+ * This method is specific to the mock implementation and is used for
269
+ * testing purposes.
270
+ */
271
+ reset(): void;
272
+ }
273
+ //#endregion
274
+ export { MockContext, MockFederation, SentActivity };