@mtcute/test 0.28.2 → 0.29.1
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/index.d.ts +1 -0
- package/index.js +2 -0
- package/package.json +5 -6
- package/schema.js +1 -1
- package/storage/peers.js +1 -2
- package/stub.d.ts +1 -1
- package/types.d.ts +1 -1
- package/worker.d.ts +4 -0
- package/worker.js +95 -0
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { defaultTestCryptoProvider, testCryptoProvider, useFakeMathRandom, withF
|
|
|
3
3
|
import { defaultCryptoProvider, defaultPlatform } from "./platform.web.js";
|
|
4
4
|
import { StubMemoryTelegramStorage } from "./storage.js";
|
|
5
5
|
import { createStub } from "./stub.js";
|
|
6
|
+
import { createTestWorkerClient } from "./worker.js";
|
|
6
7
|
import { fakeAuthKeysRepository, testAuthKeysRepository } from "./storage/auth-keys.js";
|
|
7
8
|
import { fakeKeyValueRepository, testKeyValueRepository } from "./storage/key-value.js";
|
|
8
9
|
import { fakePeersRepository, testPeersRepository } from "./storage/peers.js";
|
|
@@ -11,6 +12,7 @@ export {
|
|
|
11
12
|
StubMemoryTelegramStorage,
|
|
12
13
|
StubTelegramClient,
|
|
13
14
|
createStub,
|
|
15
|
+
createTestWorkerClient,
|
|
14
16
|
defaultCryptoProvider,
|
|
15
17
|
defaultPlatform,
|
|
16
18
|
defaultTestCryptoProvider,
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/test",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.29.1",
|
|
5
5
|
"description": "Test utilities for mtcute",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"long": "5.2
|
|
8
|
+
"long": "^5.3.2",
|
|
9
9
|
"@fuman/utils": "0.0.19",
|
|
10
10
|
"@fuman/net": "0.0.19"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@mtcute/core": "^0.
|
|
14
|
-
"@mtcute/node": "^0.
|
|
15
|
-
"@mtcute/
|
|
16
|
-
"@mtcute/web": "^0.28.2",
|
|
13
|
+
"@mtcute/core": "^0.29.1",
|
|
14
|
+
"@mtcute/node": "^0.29.1",
|
|
15
|
+
"@mtcute/web": "^0.29.1",
|
|
17
16
|
"vitest": "*"
|
|
18
17
|
},
|
|
19
18
|
"exports": {
|
package/schema.js
CHANGED
package/storage/peers.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { TlBinaryWriter } from "@mtcute/core/utils.js";
|
|
2
|
-
import { __tlWriterMap } from "@mtcute/tl/binary/writer.js";
|
|
1
|
+
import { TlBinaryWriter, __tlWriterMap } from "@mtcute/core/utils.js";
|
|
3
2
|
import { vi, describe, it, expect } from "vitest";
|
|
4
3
|
import { createStub } from "../stub.js";
|
|
5
4
|
function fakePeersRepository() {
|
package/stub.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { tl } from '@mtcute/
|
|
1
|
+
import { tl } from '@mtcute/core';
|
|
2
2
|
export declare function createStub<T extends tl.TlObject['_']>(name: T, partial?: Partial<tl.FindByName<tl.TlObject, T>>): tl.FindByName<tl.TlObject, T>;
|
package/types.d.ts
CHANGED
package/worker.d.ts
ADDED
package/worker.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Emitter } from "@fuman/utils";
|
|
2
|
+
const testPlatform = {
|
|
3
|
+
beforeExit: () => () => {
|
|
4
|
+
},
|
|
5
|
+
log: () => {
|
|
6
|
+
},
|
|
7
|
+
getDefaultLogLevel: () => 0,
|
|
8
|
+
getDeviceModel: () => "test"
|
|
9
|
+
};
|
|
10
|
+
function createTestWorkerClient(params) {
|
|
11
|
+
const stopController = new AbortController();
|
|
12
|
+
return {
|
|
13
|
+
stopSignal: stopController.signal,
|
|
14
|
+
log: { mgr: { handler: () => {
|
|
15
|
+
} } },
|
|
16
|
+
platform: testPlatform,
|
|
17
|
+
onError: new Emitter(),
|
|
18
|
+
onConnectionState: new Emitter(),
|
|
19
|
+
onServerUpdate: new Emitter(),
|
|
20
|
+
onRawUpdate: new Emitter(),
|
|
21
|
+
updates: void 0,
|
|
22
|
+
storage: {
|
|
23
|
+
self: {
|
|
24
|
+
fetch: async () => null,
|
|
25
|
+
store: async () => {
|
|
26
|
+
},
|
|
27
|
+
storeFrom: async (value) => value,
|
|
28
|
+
update: async () => {
|
|
29
|
+
},
|
|
30
|
+
getCached: () => null
|
|
31
|
+
},
|
|
32
|
+
peers: {},
|
|
33
|
+
close: async () => {
|
|
34
|
+
},
|
|
35
|
+
clear: async () => {
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
timers: {
|
|
39
|
+
upsert: async () => {
|
|
40
|
+
},
|
|
41
|
+
upsertOwned: () => {
|
|
42
|
+
},
|
|
43
|
+
cancel: async () => {
|
|
44
|
+
},
|
|
45
|
+
exists: async () => false,
|
|
46
|
+
clearOwner: () => {
|
|
47
|
+
},
|
|
48
|
+
destroy: () => {
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
appConfig: {
|
|
52
|
+
get: async () => ({}),
|
|
53
|
+
getField: async () => void 0
|
|
54
|
+
},
|
|
55
|
+
prepare: async () => {
|
|
56
|
+
},
|
|
57
|
+
connect: async () => {
|
|
58
|
+
},
|
|
59
|
+
disconnect: async () => {
|
|
60
|
+
},
|
|
61
|
+
destroy: async () => {
|
|
62
|
+
stopController.abort();
|
|
63
|
+
},
|
|
64
|
+
notifyLoggedIn: async () => {
|
|
65
|
+
},
|
|
66
|
+
notifyLoggedOut: async () => {
|
|
67
|
+
},
|
|
68
|
+
notifyChannelOpened: async () => false,
|
|
69
|
+
notifyChannelClosed: async () => false,
|
|
70
|
+
importSession: async () => {
|
|
71
|
+
},
|
|
72
|
+
exportSession: async () => "",
|
|
73
|
+
handleClientUpdate: async () => {
|
|
74
|
+
},
|
|
75
|
+
getApiCredentials: async () => ({ id: 0, hash: "" }),
|
|
76
|
+
getPoolSize: async () => 1,
|
|
77
|
+
getPrimaryDcId: async () => 2,
|
|
78
|
+
changePrimaryDc: async () => {
|
|
79
|
+
},
|
|
80
|
+
computeSrpParams: async () => ({ _: "inputCheckPasswordEmpty" }),
|
|
81
|
+
computeNewPasswordHash: async () => new Uint8Array(),
|
|
82
|
+
startUpdatesLoop: async () => {
|
|
83
|
+
},
|
|
84
|
+
stopUpdatesLoop: async () => {
|
|
85
|
+
},
|
|
86
|
+
// eslint-disable-next-line ts/no-unsafe-return
|
|
87
|
+
getMtprotoMessageId: async () => 0,
|
|
88
|
+
recreateDc: async () => {
|
|
89
|
+
},
|
|
90
|
+
call: params?.call ?? (async (message, options) => ({ message, options }))
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
createTestWorkerClient
|
|
95
|
+
};
|