signal-sdk 0.0.8 → 0.1.0
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/README.md +175 -59
- package/dist/SignalBot.d.ts +108 -0
- package/dist/SignalBot.js +811 -0
- package/dist/SignalCli.d.ts +205 -0
- package/dist/SignalCli.js +967 -0
- package/dist/__tests__/SignalBot.additional.test.d.ts +5 -0
- package/dist/__tests__/SignalBot.additional.test.js +333 -0
- package/dist/__tests__/SignalBot.test.d.ts +1 -0
- package/dist/__tests__/SignalBot.test.js +102 -0
- package/dist/__tests__/SignalCli.integration.test.d.ts +5 -0
- package/dist/__tests__/SignalCli.integration.test.js +218 -0
- package/dist/__tests__/SignalCli.methods.test.d.ts +5 -0
- package/dist/__tests__/SignalCli.methods.test.js +470 -0
- package/dist/__tests__/SignalCli.test.d.ts +1 -0
- package/dist/__tests__/SignalCli.test.js +479 -0
- package/dist/__tests__/config.test.d.ts +5 -0
- package/dist/__tests__/config.test.js +252 -0
- package/dist/__tests__/errors.test.d.ts +5 -0
- package/dist/__tests__/errors.test.js +276 -0
- package/dist/__tests__/retry.test.d.ts +4 -0
- package/dist/__tests__/retry.test.js +123 -0
- package/dist/__tests__/validators.test.d.ts +4 -0
- package/dist/__tests__/validators.test.js +147 -0
- package/dist/config.d.ts +67 -0
- package/dist/config.js +111 -0
- package/dist/errors.d.ts +32 -0
- package/dist/errors.js +75 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +26 -0
- package/dist/interfaces.d.ts +1073 -0
- package/dist/interfaces.js +11 -0
- package/dist/retry.d.ts +56 -0
- package/dist/retry.js +135 -0
- package/dist/validators.d.ts +59 -0
- package/dist/validators.js +170 -0
- package/package.json +5 -6
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tests for SignalCli methods
|
|
4
|
+
* Covers additional methods not tested in SignalCli.test.ts
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const SignalCli_1 = require("../SignalCli");
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
jest.mock('child_process');
|
|
10
|
+
describe('SignalCli Methods Tests', () => {
|
|
11
|
+
let signalCli;
|
|
12
|
+
let mockProcess;
|
|
13
|
+
let sendJsonRpcRequestSpy;
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
mockProcess = {
|
|
16
|
+
stdout: {
|
|
17
|
+
on: jest.fn(),
|
|
18
|
+
once: jest.fn(),
|
|
19
|
+
},
|
|
20
|
+
stderr: {
|
|
21
|
+
on: jest.fn(),
|
|
22
|
+
},
|
|
23
|
+
stdin: {
|
|
24
|
+
write: jest.fn(),
|
|
25
|
+
},
|
|
26
|
+
on: jest.fn(),
|
|
27
|
+
once: jest.fn(),
|
|
28
|
+
kill: jest.fn(),
|
|
29
|
+
killed: false,
|
|
30
|
+
};
|
|
31
|
+
const spawnMock = child_process_1.spawn;
|
|
32
|
+
spawnMock.mockReturnValue(mockProcess);
|
|
33
|
+
signalCli = new SignalCli_1.SignalCli('signal-cli', '+1234567890');
|
|
34
|
+
// Mock sendJsonRpcRequest to avoid needing actual connection
|
|
35
|
+
sendJsonRpcRequestSpy = jest.spyOn(signalCli, 'sendJsonRpcRequest').mockResolvedValue({});
|
|
36
|
+
});
|
|
37
|
+
afterEach(() => {
|
|
38
|
+
if (signalCli) {
|
|
39
|
+
signalCli.disconnect();
|
|
40
|
+
}
|
|
41
|
+
jest.clearAllMocks();
|
|
42
|
+
});
|
|
43
|
+
describe('Message Methods', () => {
|
|
44
|
+
it('should send message to individual', async () => {
|
|
45
|
+
await signalCli.sendMessage('+1234567890', 'Hello');
|
|
46
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('send', expect.objectContaining({
|
|
47
|
+
message: 'Hello',
|
|
48
|
+
recipients: ['+1234567890'],
|
|
49
|
+
account: '+1234567890'
|
|
50
|
+
}));
|
|
51
|
+
});
|
|
52
|
+
it('should send message to group', async () => {
|
|
53
|
+
await signalCli.sendMessage('group123==', 'Hello group');
|
|
54
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('send', expect.objectContaining({
|
|
55
|
+
message: 'Hello group',
|
|
56
|
+
groupId: 'group123=='
|
|
57
|
+
}));
|
|
58
|
+
});
|
|
59
|
+
it('should send message with attachments', async () => {
|
|
60
|
+
await signalCli.sendMessage('+1234567890', 'Check this', { attachments: ['/path/to/file.jpg'] });
|
|
61
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('send', expect.objectContaining({
|
|
62
|
+
attachments: ['/path/to/file.jpg']
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
it('should send message with expiration', async () => {
|
|
66
|
+
await signalCli.sendMessage('+1234567890', 'Secret', { expiresInSeconds: 3600 });
|
|
67
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('send', expect.objectContaining({
|
|
68
|
+
expiresInSeconds: 3600
|
|
69
|
+
}));
|
|
70
|
+
});
|
|
71
|
+
it('should send view-once message', async () => {
|
|
72
|
+
await signalCli.sendMessage('+1234567890', 'View once', { isViewOnce: true });
|
|
73
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('send', expect.objectContaining({
|
|
74
|
+
isViewOnce: true
|
|
75
|
+
}));
|
|
76
|
+
});
|
|
77
|
+
it('should send reaction', async () => {
|
|
78
|
+
await signalCli.sendReaction('+1234567890', '+0987654321', 123456, '👍');
|
|
79
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('sendReaction', expect.objectContaining({
|
|
80
|
+
emoji: '👍',
|
|
81
|
+
targetAuthor: '+0987654321',
|
|
82
|
+
targetTimestamp: 123456,
|
|
83
|
+
remove: false,
|
|
84
|
+
account: '+1234567890'
|
|
85
|
+
}));
|
|
86
|
+
});
|
|
87
|
+
it('should send reaction with remove flag', async () => {
|
|
88
|
+
await signalCli.sendReaction('+1234567890', '+0987654321', 123456, '👍', true);
|
|
89
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('sendReaction', expect.objectContaining({
|
|
90
|
+
remove: true
|
|
91
|
+
}));
|
|
92
|
+
});
|
|
93
|
+
it('should send reaction to group', async () => {
|
|
94
|
+
await signalCli.sendReaction('group123==', '+0987654321', 123456, '👍');
|
|
95
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('sendReaction', expect.objectContaining({
|
|
96
|
+
groupId: 'group123=='
|
|
97
|
+
}));
|
|
98
|
+
});
|
|
99
|
+
it('should send typing indicator', async () => {
|
|
100
|
+
await signalCli.sendTyping('+1234567890');
|
|
101
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('sendTyping', expect.objectContaining({
|
|
102
|
+
when: true,
|
|
103
|
+
recipients: ['+1234567890']
|
|
104
|
+
}));
|
|
105
|
+
});
|
|
106
|
+
it('should stop typing indicator', async () => {
|
|
107
|
+
await signalCli.sendTyping('+1234567890', true);
|
|
108
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('sendTyping', expect.objectContaining({
|
|
109
|
+
when: false
|
|
110
|
+
}));
|
|
111
|
+
});
|
|
112
|
+
it('should remote delete message', async () => {
|
|
113
|
+
await signalCli.remoteDeleteMessage('+1234567890', 123456);
|
|
114
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('remoteDelete', expect.objectContaining({
|
|
115
|
+
targetTimestamp: 123456,
|
|
116
|
+
recipients: ['+1234567890']
|
|
117
|
+
}));
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
describe('Contact Methods', () => {
|
|
121
|
+
it('should update contact', async () => {
|
|
122
|
+
await signalCli.updateContact('+1234567890', 'John Doe');
|
|
123
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('updateContact', expect.objectContaining({
|
|
124
|
+
recipient: '+1234567890',
|
|
125
|
+
name: 'John Doe'
|
|
126
|
+
}));
|
|
127
|
+
});
|
|
128
|
+
it('should update contact with options', async () => {
|
|
129
|
+
await signalCli.updateContact('+1234567890', 'John Doe', { color: 'blue', muted: true });
|
|
130
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('updateContact', expect.objectContaining({
|
|
131
|
+
name: 'John Doe',
|
|
132
|
+
color: 'blue',
|
|
133
|
+
muted: true
|
|
134
|
+
}));
|
|
135
|
+
});
|
|
136
|
+
it('should block recipients', async () => {
|
|
137
|
+
await signalCli.block(['+1111111111', '+2222222222']);
|
|
138
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('block', expect.objectContaining({
|
|
139
|
+
recipient: ['+1111111111', '+2222222222']
|
|
140
|
+
}));
|
|
141
|
+
});
|
|
142
|
+
it('should block group', async () => {
|
|
143
|
+
await signalCli.block([], 'group123==');
|
|
144
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('block', expect.objectContaining({
|
|
145
|
+
groupId: 'group123=='
|
|
146
|
+
}));
|
|
147
|
+
});
|
|
148
|
+
it('should unblock recipients', async () => {
|
|
149
|
+
await signalCli.unblock(['+1111111111']);
|
|
150
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('unblock', expect.objectContaining({
|
|
151
|
+
recipient: ['+1111111111']
|
|
152
|
+
}));
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
describe('Group Methods', () => {
|
|
156
|
+
it('should quit group', async () => {
|
|
157
|
+
await signalCli.quitGroup('group123==');
|
|
158
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('quitGroup', expect.objectContaining({
|
|
159
|
+
groupId: 'group123=='
|
|
160
|
+
}));
|
|
161
|
+
});
|
|
162
|
+
it('should join group', async () => {
|
|
163
|
+
await signalCli.joinGroup('https://signal.group/...');
|
|
164
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('joinGroup', expect.objectContaining({
|
|
165
|
+
uri: 'https://signal.group/...'
|
|
166
|
+
}));
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
describe('Profile Methods', () => {
|
|
170
|
+
it('should update profile with name only', async () => {
|
|
171
|
+
await signalCli.updateProfile('John Doe');
|
|
172
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('updateProfile', expect.objectContaining({
|
|
173
|
+
name: 'John Doe'
|
|
174
|
+
}));
|
|
175
|
+
});
|
|
176
|
+
it('should update profile with all fields', async () => {
|
|
177
|
+
await signalCli.updateProfile('John Doe', 'Hello!', '👋', '/path/to/avatar.jpg');
|
|
178
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('updateProfile', expect.objectContaining({
|
|
179
|
+
name: 'John Doe',
|
|
180
|
+
about: 'Hello!',
|
|
181
|
+
aboutEmoji: '👋',
|
|
182
|
+
avatar: '/path/to/avatar.jpg'
|
|
183
|
+
}));
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
describe('Receipt Methods', () => {
|
|
187
|
+
it('should send read receipt', async () => {
|
|
188
|
+
await signalCli.sendReceipt('+1234567890', 123456);
|
|
189
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('sendReceipt', expect.objectContaining({
|
|
190
|
+
recipient: '+1234567890',
|
|
191
|
+
targetTimestamp: 123456,
|
|
192
|
+
type: 'read'
|
|
193
|
+
}));
|
|
194
|
+
});
|
|
195
|
+
it('should send viewed receipt', async () => {
|
|
196
|
+
await signalCli.sendReceipt('+1234567890', 123456, 'viewed');
|
|
197
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('sendReceipt', expect.objectContaining({
|
|
198
|
+
type: 'viewed'
|
|
199
|
+
}));
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
describe('Sticker Methods', () => {
|
|
203
|
+
it('should list sticker packs', async () => {
|
|
204
|
+
sendJsonRpcRequestSpy.mockResolvedValue([{ id: 'pack1', title: 'Pack 1' }]);
|
|
205
|
+
const packs = await signalCli.listStickerPacks();
|
|
206
|
+
expect(packs).toHaveLength(1);
|
|
207
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('listStickerPacks', expect.objectContaining({
|
|
208
|
+
account: '+1234567890'
|
|
209
|
+
}));
|
|
210
|
+
});
|
|
211
|
+
it('should add sticker pack', async () => {
|
|
212
|
+
await signalCli.addStickerPack('packId123', 'packKey456');
|
|
213
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('addStickerPack', expect.objectContaining({
|
|
214
|
+
packId: 'packId123',
|
|
215
|
+
packKey: 'packKey456'
|
|
216
|
+
}));
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
describe('Account Methods', () => {
|
|
220
|
+
it('should register account', async () => {
|
|
221
|
+
await signalCli.register('+1234567890');
|
|
222
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('register', expect.objectContaining({
|
|
223
|
+
account: '+1234567890'
|
|
224
|
+
}));
|
|
225
|
+
});
|
|
226
|
+
it('should register with voice and captcha', async () => {
|
|
227
|
+
await signalCli.register('+1234567890', true, 'captcha123');
|
|
228
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('register', expect.objectContaining({
|
|
229
|
+
account: '+1234567890',
|
|
230
|
+
voice: true,
|
|
231
|
+
captcha: 'captcha123'
|
|
232
|
+
}));
|
|
233
|
+
});
|
|
234
|
+
it('should verify account', async () => {
|
|
235
|
+
await signalCli.verify('+1234567890', 'token123');
|
|
236
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('verify', expect.objectContaining({
|
|
237
|
+
account: '+1234567890',
|
|
238
|
+
token: 'token123'
|
|
239
|
+
}));
|
|
240
|
+
});
|
|
241
|
+
it('should verify with PIN', async () => {
|
|
242
|
+
await signalCli.verify('+1234567890', 'token123', '1234');
|
|
243
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('verify', expect.objectContaining({
|
|
244
|
+
pin: '1234'
|
|
245
|
+
}));
|
|
246
|
+
});
|
|
247
|
+
it('should unregister account', async () => {
|
|
248
|
+
await signalCli.unregister();
|
|
249
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('unregister', expect.objectContaining({
|
|
250
|
+
account: '+1234567890'
|
|
251
|
+
}));
|
|
252
|
+
});
|
|
253
|
+
it('should delete local account data', async () => {
|
|
254
|
+
await signalCli.deleteLocalAccountData();
|
|
255
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('deleteLocalAccountData', expect.objectContaining({
|
|
256
|
+
account: '+1234567890'
|
|
257
|
+
}));
|
|
258
|
+
});
|
|
259
|
+
it('should update account configuration', async () => {
|
|
260
|
+
const config = { readReceipts: true, typingIndicators: true };
|
|
261
|
+
await signalCli.updateAccountConfiguration(config);
|
|
262
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('updateConfiguration', expect.objectContaining({
|
|
263
|
+
readReceipts: true,
|
|
264
|
+
typingIndicators: true
|
|
265
|
+
}));
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
describe('Device Methods', () => {
|
|
269
|
+
it('should remove device', async () => {
|
|
270
|
+
await signalCli.removeDevice(2);
|
|
271
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('removeDevice', expect.objectContaining({
|
|
272
|
+
deviceId: 2
|
|
273
|
+
}));
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
describe('PIN Methods', () => {
|
|
277
|
+
it('should set PIN', async () => {
|
|
278
|
+
await signalCli.setPin('1234');
|
|
279
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('setPin', expect.objectContaining({
|
|
280
|
+
pin: '1234'
|
|
281
|
+
}));
|
|
282
|
+
});
|
|
283
|
+
it('should remove PIN', async () => {
|
|
284
|
+
await signalCli.removePin();
|
|
285
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('removePin', expect.objectContaining({
|
|
286
|
+
account: '+1234567890'
|
|
287
|
+
}));
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
describe('Identity Methods', () => {
|
|
291
|
+
it('should list all identities', async () => {
|
|
292
|
+
sendJsonRpcRequestSpy.mockResolvedValue([{ number: '+1111111111' }]);
|
|
293
|
+
const identities = await signalCli.listIdentities();
|
|
294
|
+
expect(identities).toHaveLength(1);
|
|
295
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('listIdentities', expect.objectContaining({
|
|
296
|
+
account: '+1234567890'
|
|
297
|
+
}));
|
|
298
|
+
});
|
|
299
|
+
it('should list identities for specific number', async () => {
|
|
300
|
+
sendJsonRpcRequestSpy.mockResolvedValue([{ number: '+1111111111' }]);
|
|
301
|
+
await signalCli.listIdentities('+1111111111');
|
|
302
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('listIdentities', expect.objectContaining({
|
|
303
|
+
number: '+1111111111'
|
|
304
|
+
}));
|
|
305
|
+
});
|
|
306
|
+
it('should trust identity', async () => {
|
|
307
|
+
await signalCli.trustIdentity('+1111111111', 'fingerprint123');
|
|
308
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('trust', expect.objectContaining({
|
|
309
|
+
recipient: '+1111111111',
|
|
310
|
+
safetyNumber: 'fingerprint123',
|
|
311
|
+
verified: true
|
|
312
|
+
}));
|
|
313
|
+
});
|
|
314
|
+
it('should trust identity with verified flag', async () => {
|
|
315
|
+
await signalCli.trustIdentity('+1111111111', 'fingerprint123', false);
|
|
316
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('trust', expect.objectContaining({
|
|
317
|
+
verified: false
|
|
318
|
+
}));
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
describe('Link Methods', () => {
|
|
322
|
+
it('should initiate device link', async () => {
|
|
323
|
+
sendJsonRpcRequestSpy.mockResolvedValue({ uri: 'sgnl://link?...' });
|
|
324
|
+
const uri = await signalCli.link('MyDevice');
|
|
325
|
+
expect(uri).toBe('sgnl://link?...');
|
|
326
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('link', {
|
|
327
|
+
deviceName: 'MyDevice'
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
it('should link without device name', async () => {
|
|
331
|
+
sendJsonRpcRequestSpy.mockResolvedValue({ uri: 'sgnl://link?...' });
|
|
332
|
+
await signalCli.link();
|
|
333
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('link', {
|
|
334
|
+
deviceName: undefined
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
describe('Poll Methods', () => {
|
|
339
|
+
it('should send poll create to group', async () => {
|
|
340
|
+
await signalCli.sendPollCreate({
|
|
341
|
+
question: 'What is your favorite color?',
|
|
342
|
+
options: ['Red', 'Blue', 'Green'],
|
|
343
|
+
groupId: 'group123=='
|
|
344
|
+
});
|
|
345
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('sendPollCreate', expect.objectContaining({
|
|
346
|
+
question: 'What is your favorite color?',
|
|
347
|
+
options: ['Red', 'Blue', 'Green'],
|
|
348
|
+
groupId: 'group123=='
|
|
349
|
+
}));
|
|
350
|
+
});
|
|
351
|
+
it('should send poll create to recipients', async () => {
|
|
352
|
+
await signalCli.sendPollCreate({
|
|
353
|
+
question: 'What is your favorite color?',
|
|
354
|
+
options: ['Red', 'Blue'],
|
|
355
|
+
recipients: ['+1111111111', '+2222222222']
|
|
356
|
+
});
|
|
357
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('sendPollCreate', expect.objectContaining({
|
|
358
|
+
recipients: ['+1111111111', '+2222222222']
|
|
359
|
+
}));
|
|
360
|
+
});
|
|
361
|
+
it('should send poll create with multiSelect', async () => {
|
|
362
|
+
await signalCli.sendPollCreate({
|
|
363
|
+
question: 'Select options',
|
|
364
|
+
options: ['A', 'B', 'C'],
|
|
365
|
+
groupId: 'group123==',
|
|
366
|
+
multiSelect: true
|
|
367
|
+
});
|
|
368
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('sendPollCreate', expect.objectContaining({
|
|
369
|
+
multiSelect: true
|
|
370
|
+
}));
|
|
371
|
+
});
|
|
372
|
+
it('should send poll vote to individual', async () => {
|
|
373
|
+
await signalCli.sendPollVote('+1234567890', {
|
|
374
|
+
pollAuthor: '+9876543210',
|
|
375
|
+
pollTimestamp: 123456,
|
|
376
|
+
optionIndexes: [0, 2]
|
|
377
|
+
});
|
|
378
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('sendPollVote', expect.objectContaining({
|
|
379
|
+
pollAuthor: '+9876543210',
|
|
380
|
+
pollTimestamp: 123456,
|
|
381
|
+
options: [0, 2],
|
|
382
|
+
recipient: '+1234567890'
|
|
383
|
+
}));
|
|
384
|
+
});
|
|
385
|
+
it('should send poll vote to group', async () => {
|
|
386
|
+
await signalCli.sendPollVote('group123==', {
|
|
387
|
+
pollAuthor: '+9876543210',
|
|
388
|
+
pollTimestamp: 123456,
|
|
389
|
+
optionIndexes: [1]
|
|
390
|
+
});
|
|
391
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('sendPollVote', expect.objectContaining({
|
|
392
|
+
groupId: 'group123=='
|
|
393
|
+
}));
|
|
394
|
+
});
|
|
395
|
+
it('should send poll terminate', async () => {
|
|
396
|
+
await signalCli.sendPollTerminate('+1234567890', {
|
|
397
|
+
pollTimestamp: 123456
|
|
398
|
+
});
|
|
399
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('sendPollTerminate', expect.objectContaining({
|
|
400
|
+
pollTimestamp: 123456
|
|
401
|
+
}));
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
describe('Update Account Methods', () => {
|
|
405
|
+
it('should update account with device name', async () => {
|
|
406
|
+
sendJsonRpcRequestSpy.mockResolvedValue({ username: 'user.123' });
|
|
407
|
+
const result = await signalCli.updateAccount({ deviceName: 'New Device' });
|
|
408
|
+
expect(result.success).toBe(true);
|
|
409
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('updateAccount', expect.objectContaining({
|
|
410
|
+
deviceName: 'New Device'
|
|
411
|
+
}));
|
|
412
|
+
});
|
|
413
|
+
it('should update account with username', async () => {
|
|
414
|
+
sendJsonRpcRequestSpy.mockResolvedValue({ username: 'newuser.456', usernameLink: 'link' });
|
|
415
|
+
const result = await signalCli.updateAccount({ username: 'newuser.456' });
|
|
416
|
+
expect(result.success).toBe(true);
|
|
417
|
+
expect(result.username).toBe('newuser.456');
|
|
418
|
+
});
|
|
419
|
+
it('should delete username', async () => {
|
|
420
|
+
sendJsonRpcRequestSpy.mockResolvedValue({});
|
|
421
|
+
await signalCli.updateAccount({ deleteUsername: true });
|
|
422
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('updateAccount', expect.objectContaining({
|
|
423
|
+
deleteUsername: true
|
|
424
|
+
}));
|
|
425
|
+
});
|
|
426
|
+
it('should update privacy settings', async () => {
|
|
427
|
+
sendJsonRpcRequestSpy.mockResolvedValue({});
|
|
428
|
+
await signalCli.updateAccount({
|
|
429
|
+
unrestrictedUnidentifiedSender: true,
|
|
430
|
+
discoverableByNumber: false,
|
|
431
|
+
numberSharing: false
|
|
432
|
+
});
|
|
433
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('updateAccount', expect.objectContaining({
|
|
434
|
+
unrestrictedUnidentifiedSender: true,
|
|
435
|
+
discoverableByNumber: false,
|
|
436
|
+
numberSharing: false
|
|
437
|
+
}));
|
|
438
|
+
});
|
|
439
|
+
it('should handle update account error', async () => {
|
|
440
|
+
sendJsonRpcRequestSpy.mockRejectedValue(new Error('Update failed'));
|
|
441
|
+
const result = await signalCli.updateAccount({ deviceName: 'Device' });
|
|
442
|
+
expect(result.success).toBe(false);
|
|
443
|
+
expect(result.error).toBe('Update failed');
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
describe('Attachment Methods', () => {
|
|
447
|
+
it('should get attachment by ID', async () => {
|
|
448
|
+
sendJsonRpcRequestSpy.mockResolvedValue({ data: 'base64data...' });
|
|
449
|
+
const data = await signalCli.getAttachment({ id: 'attachment123' });
|
|
450
|
+
expect(data).toBe('base64data...');
|
|
451
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('getAttachment', expect.objectContaining({
|
|
452
|
+
id: 'attachment123'
|
|
453
|
+
}));
|
|
454
|
+
});
|
|
455
|
+
it('should get attachment with groupId', async () => {
|
|
456
|
+
sendJsonRpcRequestSpy.mockResolvedValue('base64data');
|
|
457
|
+
await signalCli.getAttachment({ id: 'att1', groupId: 'group123==' });
|
|
458
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('getAttachment', expect.objectContaining({
|
|
459
|
+
groupId: 'group123=='
|
|
460
|
+
}));
|
|
461
|
+
});
|
|
462
|
+
it('should get attachment with recipient', async () => {
|
|
463
|
+
sendJsonRpcRequestSpy.mockResolvedValue('base64data');
|
|
464
|
+
await signalCli.getAttachment({ id: 'att1', recipient: '+1111111111' });
|
|
465
|
+
expect(sendJsonRpcRequestSpy).toHaveBeenCalledWith('getAttachment', expect.objectContaining({
|
|
466
|
+
recipient: '+1111111111'
|
|
467
|
+
}));
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|