hivesigner 3.3.5 → 4.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 +29 -2
- package/lib/client.d.ts +19 -3
- package/lib/hivesigner.min.js +1 -10
- package/lib/index.d.ts +4 -0
- package/lib/index.js +194 -225
- package/lib/methods/send-operation.method.d.ts +1 -2
- package/lib/methods/send-operations.method.d.ts +1 -2
- package/lib/methods/send-transaction.method.d.ts +1 -2
- package/lib/pkce.d.ts +16 -0
- package/lib/types/callback-function.type.d.ts +1 -1
- package/lib/types/hive.types.d.ts +13 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/login-options.interface.d.ts +2 -0
- package/lib/types/send-response.type.d.ts +1 -1
- package/lib/types/token-response.interface.d.ts +8 -0
- package/package.json +11 -18
- package/.babelrc +0 -8
- package/.claude/settings.local.json +0 -12
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -16
- package/CLAUDE.md +0 -142
- package/docs/CNAME +0 -1
- package/docs/index.html +0 -221
- package/jest.config.js +0 -10
- package/rollup.config.js +0 -12
- package/src/client.spec.ts +0 -455
- package/src/client.ts +0 -317
- package/src/consts/api-url.const.ts +0 -1
- package/src/consts/base-url.const.ts +0 -1
- package/src/consts/beta-url.const.ts +0 -1
- package/src/consts/index.ts +0 -3
- package/src/default-import.spec.ts +0 -10
- package/src/factories/index.ts +0 -1
- package/src/factories/initialize.factory.spec.ts +0 -9
- package/src/factories/initialize.factory.ts +0 -7
- package/src/index.ts +0 -16
- package/src/methods/index.ts +0 -4
- package/src/methods/send-operation.method.spec.ts +0 -47
- package/src/methods/send-operation.method.ts +0 -15
- package/src/methods/send-operations.method.spec.ts +0 -47
- package/src/methods/send-operations.method.ts +0 -15
- package/src/methods/send-transaction.method.spec.ts +0 -47
- package/src/methods/send-transaction.method.ts +0 -15
- package/src/methods/sign.method.spec.ts +0 -60
- package/src/methods/sign.method.ts +0 -22
- package/src/modules-import.spec.ts +0 -11
- package/src/require-import.spec.js +0 -11
- package/src/require-import.spec.ts +0 -10
- package/src/types/callback-function.type.ts +0 -1
- package/src/types/client-config.interface.ts +0 -8
- package/src/types/index.ts +0 -5
- package/src/types/login-options.interface.ts +0 -3
- package/src/types/send-response.type.ts +0 -1
- package/src/types/sign-errors.interface.ts +0 -4
- package/src/utilities/index.ts +0 -1
- package/src/utilities/is-browser.util.ts +0 -3
- package/tsconfig.json +0 -15
- package/webpack.config.js +0 -26
package/src/client.spec.ts
DELETED
|
@@ -1,455 +0,0 @@
|
|
|
1
|
-
import { Client } from './client'
|
|
2
|
-
import { ClientConfig } from './types'
|
|
3
|
-
import { API_URL, BASE_URL } from './consts'
|
|
4
|
-
import * as utilities from './utilities'
|
|
5
|
-
import * as crossFetch from 'cross-fetch'
|
|
6
|
-
|
|
7
|
-
jest.mock('./utilities')
|
|
8
|
-
jest.mock('cross-fetch')
|
|
9
|
-
|
|
10
|
-
describe('Client', function () {
|
|
11
|
-
let instance: Client
|
|
12
|
-
let isBrowserMock: jest.Mock
|
|
13
|
-
let crossFetchMock: jest.Mock
|
|
14
|
-
let crossFetchResponseMock: { status: string | number, json: () => {} }
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
instance = new Client({
|
|
18
|
-
app: 'test-app',
|
|
19
|
-
callbackURL: 'test-callback',
|
|
20
|
-
apiURL: API_URL,
|
|
21
|
-
accessToken: 'test-access-token',
|
|
22
|
-
responseType: 'test-response-type',
|
|
23
|
-
scope: ['test-scope-item'],
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
isBrowserMock = utilities.isBrowser as jest.Mock
|
|
27
|
-
isBrowserMock.mockReturnValue(false)
|
|
28
|
-
|
|
29
|
-
crossFetchResponseMock = {
|
|
30
|
-
status: 200,
|
|
31
|
-
json: async () => ({ error: '' })
|
|
32
|
-
}
|
|
33
|
-
crossFetchMock = crossFetch.fetch as jest.Mock
|
|
34
|
-
crossFetchMock.mockImplementation(async (...args: any[]) => crossFetchResponseMock)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('should create instance', function () {
|
|
38
|
-
expect(new Client({} as ClientConfig)).toBeInstanceOf(Client)
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('should set api url', function () {
|
|
42
|
-
instance.setApiURL('another-test-api-url')
|
|
43
|
-
expect(instance.apiURL).toBe('another-test-api-url')
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('should set app', function () {
|
|
47
|
-
instance.setApp('another-app')
|
|
48
|
-
expect(instance.app).toBe('another-app')
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it('should set callback url', function () {
|
|
52
|
-
instance.setCallbackURL('another-url')
|
|
53
|
-
expect(instance.callbackURL).toBe('another-url')
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('should set access token', function () {
|
|
57
|
-
instance.setAccessToken('another-token')
|
|
58
|
-
expect(instance.accessToken).toBe('another-token')
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it('should remove access token', function () {
|
|
62
|
-
instance.removeAccessToken()
|
|
63
|
-
expect(instance.accessToken).toBeFalsy()
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('should set scope', function () {
|
|
67
|
-
instance.setScope([])
|
|
68
|
-
expect(instance.scope).toStrictEqual([])
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it('should return login url', function () {
|
|
72
|
-
instance.scope = null
|
|
73
|
-
expect(instance.getLoginURL(''))
|
|
74
|
-
.toBe(`${BASE_URL}/oauth2/authorize?client_id=test-app&redirect_uri=${encodeURIComponent(instance.callbackURL)}`)
|
|
75
|
-
|
|
76
|
-
instance.scope = ['test-scope', 'test-scope-1']
|
|
77
|
-
expect(instance.getLoginURL(''))
|
|
78
|
-
.toBe(`${BASE_URL}/oauth2/authorize?client_id=test-app&redirect_uri=${encodeURIComponent(instance.callbackURL)}&scope=test-scope,test-scope-1`)
|
|
79
|
-
|
|
80
|
-
instance.responseType = 'code'
|
|
81
|
-
expect(instance.getLoginURL(''))
|
|
82
|
-
.toBe(`${BASE_URL}/oauth2/authorize?client_id=test-app&redirect_uri=${encodeURIComponent(instance.callbackURL)}&response_type=code&scope=test-scope,test-scope-1`)
|
|
83
|
-
|
|
84
|
-
expect(instance.getLoginURL('state'))
|
|
85
|
-
.toBe(`${BASE_URL}/oauth2/authorize?client_id=test-app&redirect_uri=${encodeURIComponent(instance.callbackURL)}&response_type=code&scope=test-scope,test-scope-1&state=state`)
|
|
86
|
-
|
|
87
|
-
expect(instance.getLoginURL('state', 'demo'))
|
|
88
|
-
.toBe(`${BASE_URL}/oauth2/authorize?client_id=test-app&redirect_uri=${encodeURIComponent(instance.callbackURL)}&response_type=code&scope=test-scope,test-scope-1&state=state&account=demo`)
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('should change window location on login if its browser', function () {
|
|
92
|
-
isBrowserMock.mockReturnValue(false)
|
|
93
|
-
instance.login({ state: '' })
|
|
94
|
-
expect(window.location).toBe('')
|
|
95
|
-
|
|
96
|
-
isBrowserMock.mockReturnValue(true)
|
|
97
|
-
instance.login({ state: '' })
|
|
98
|
-
expect(window.location)
|
|
99
|
-
.toBe(`${BASE_URL}/oauth2/authorize?client_id=test-app&redirect_uri=${encodeURIComponent(instance.callbackURL)}&scope=test-scope-item`)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('should return promise resolve on send call', async function () {
|
|
103
|
-
const response = await instance.send('me', 'POST', {})
|
|
104
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/me`,{
|
|
105
|
-
method: 'POST',
|
|
106
|
-
headers: {
|
|
107
|
-
Accept: 'application/json, text/plain, */*',
|
|
108
|
-
'Content-Type': 'application/json',
|
|
109
|
-
Authorization: 'test-access-token',
|
|
110
|
-
},
|
|
111
|
-
body: JSON.stringify({})
|
|
112
|
-
})
|
|
113
|
-
expect(response).toStrictEqual(await crossFetchResponseMock.json())
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
it('should return promise error on send call with if 200 status', async function () {
|
|
117
|
-
crossFetchResponseMock = {
|
|
118
|
-
status: 'not_200_OK',
|
|
119
|
-
json: async () => ({ error: '' })
|
|
120
|
-
}
|
|
121
|
-
try {
|
|
122
|
-
const response = await instance.send('me', 'POST', {})
|
|
123
|
-
// Test should be broken
|
|
124
|
-
console.error('Client.send not threw error')
|
|
125
|
-
expect(true).toBe(false)
|
|
126
|
-
} catch (failureResponse) {
|
|
127
|
-
expect(failureResponse).toStrictEqual(await crossFetchResponseMock.json())
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
it('should return promise error on send call if has json error', async function () {
|
|
132
|
-
crossFetchResponseMock = {
|
|
133
|
-
status: 200,
|
|
134
|
-
json: async () => ({ error: 'I have an error' })
|
|
135
|
-
}
|
|
136
|
-
try {
|
|
137
|
-
const response = await instance.send('me', 'POST', {})
|
|
138
|
-
// Test should be broken
|
|
139
|
-
console.error('Client.send not threw error')
|
|
140
|
-
expect(true).toBe(false)
|
|
141
|
-
} catch (failureResponse) {
|
|
142
|
-
expect(failureResponse).toBeTruthy()
|
|
143
|
-
expect(failureResponse).toStrictEqual(await crossFetchResponseMock.json())
|
|
144
|
-
}
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
it('should return promise with results on send call with callback', async function () {
|
|
148
|
-
const callback = jest.fn().mockReturnValue('results')
|
|
149
|
-
const response = await instance.send('me', 'POST', {}, callback)
|
|
150
|
-
|
|
151
|
-
expect(callback).toHaveBeenCalled()
|
|
152
|
-
expect(callback).toHaveBeenCalledWith(null, await crossFetchResponseMock.json())
|
|
153
|
-
expect(callback).lastReturnedWith('results')
|
|
154
|
-
expect(response).toBe('results')
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
it('should return promise with failure results on send call with callback', async function () {
|
|
158
|
-
const callback = jest.fn().mockReturnValue('results')
|
|
159
|
-
crossFetchResponseMock = {
|
|
160
|
-
status: 'not_200_OK',
|
|
161
|
-
json: async () => ({ error: '' })
|
|
162
|
-
}
|
|
163
|
-
const response = await instance.send('me', 'POST', {}, callback)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
expect(callback).toHaveBeenCalled()
|
|
167
|
-
expect(callback).toHaveBeenCalledWith(await crossFetchResponseMock.json(), null)
|
|
168
|
-
expect(callback).lastReturnedWith('results')
|
|
169
|
-
expect(response).toBe('results')
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
it('should return promise on broadcast call', async function () {
|
|
173
|
-
const response = await instance.broadcast([])
|
|
174
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
|
|
175
|
-
method: 'POST',
|
|
176
|
-
headers: {
|
|
177
|
-
Accept: 'application/json, text/plain, */*',
|
|
178
|
-
'Content-Type': 'application/json',
|
|
179
|
-
Authorization: 'test-access-token',
|
|
180
|
-
},
|
|
181
|
-
body: JSON.stringify({ operations: [] })
|
|
182
|
-
})
|
|
183
|
-
expect(response).toBeTruthy()
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
it('should return promise on updateUserMetadata call', async function () {
|
|
187
|
-
const response = await instance.updateUserMetadata({ username: '' })
|
|
188
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/me`,{
|
|
189
|
-
method: 'PUT',
|
|
190
|
-
headers: {
|
|
191
|
-
Accept: 'application/json, text/plain, */*',
|
|
192
|
-
'Content-Type': 'application/json',
|
|
193
|
-
Authorization: 'test-access-token',
|
|
194
|
-
},
|
|
195
|
-
body: JSON.stringify({ user_metadata: { username: '' } })
|
|
196
|
-
})
|
|
197
|
-
expect(response).toBeTruthy()
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
it('should send request and return client instance on revokeToken call', async function () {
|
|
201
|
-
const response = await instance.revokeToken()
|
|
202
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/oauth2/token/revoke`,{
|
|
203
|
-
method: 'POST',
|
|
204
|
-
headers: {
|
|
205
|
-
Accept: 'application/json, text/plain, */*',
|
|
206
|
-
'Content-Type': 'application/json',
|
|
207
|
-
Authorization: 'test-access-token',
|
|
208
|
-
},
|
|
209
|
-
body: JSON.stringify({ token: 'test-access-token' })
|
|
210
|
-
})
|
|
211
|
-
expect(response).toBeInstanceOf(Client)
|
|
212
|
-
})
|
|
213
|
-
|
|
214
|
-
it('should send request and return promise on claimRewardBalance call', async function () {
|
|
215
|
-
const response = await instance.claimRewardBalance('', '', '', '')
|
|
216
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
|
|
217
|
-
method: 'POST',
|
|
218
|
-
headers: {
|
|
219
|
-
Accept: 'application/json, text/plain, */*',
|
|
220
|
-
'Content-Type': 'application/json',
|
|
221
|
-
Authorization: 'test-access-token',
|
|
222
|
-
},
|
|
223
|
-
body: JSON.stringify({
|
|
224
|
-
operations: [['claim_reward_balance', {
|
|
225
|
-
account: '',
|
|
226
|
-
reward_hive: '',
|
|
227
|
-
reward_hbd: '',
|
|
228
|
-
reward_vests: ''
|
|
229
|
-
}]]
|
|
230
|
-
})
|
|
231
|
-
})
|
|
232
|
-
expect(response).toBeTruthy()
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
it('should send request and return promise on custom json call', async function () {
|
|
236
|
-
const response = await instance.customJson('', '', '', {})
|
|
237
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
|
|
238
|
-
method: 'POST',
|
|
239
|
-
headers: {
|
|
240
|
-
Accept: 'application/json, text/plain, */*',
|
|
241
|
-
'Content-Type': 'application/json',
|
|
242
|
-
Authorization: 'test-access-token',
|
|
243
|
-
},
|
|
244
|
-
body: JSON.stringify({
|
|
245
|
-
operations: [['custom_json', {
|
|
246
|
-
required_auths: '',
|
|
247
|
-
required_posting_auths: '',
|
|
248
|
-
id: '',
|
|
249
|
-
json: {}
|
|
250
|
-
}]]
|
|
251
|
-
})
|
|
252
|
-
})
|
|
253
|
-
expect(response).toBeTruthy()
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
it('should send request and return promise on ignore call', async function () {
|
|
257
|
-
const response = await instance.ignore('', '')
|
|
258
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
|
|
259
|
-
method: 'POST',
|
|
260
|
-
headers: {
|
|
261
|
-
Accept: 'application/json, text/plain, */*',
|
|
262
|
-
'Content-Type': 'application/json',
|
|
263
|
-
Authorization: 'test-access-token',
|
|
264
|
-
},
|
|
265
|
-
body: JSON.stringify({
|
|
266
|
-
operations: [['custom_json', {
|
|
267
|
-
required_auths: [],
|
|
268
|
-
required_posting_auths: [''],
|
|
269
|
-
id: 'follow',
|
|
270
|
-
json: JSON.stringify(['follow', {
|
|
271
|
-
follower: '',
|
|
272
|
-
following: '',
|
|
273
|
-
what: ['ignore']
|
|
274
|
-
}])
|
|
275
|
-
}]]
|
|
276
|
-
})
|
|
277
|
-
})
|
|
278
|
-
expect(response).toBeTruthy()
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
it('should send request and return promise on unfollow call', async function () {
|
|
282
|
-
const response = await instance.unfollow('', '')
|
|
283
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
|
|
284
|
-
method: 'POST',
|
|
285
|
-
headers: {
|
|
286
|
-
Accept: 'application/json, text/plain, */*',
|
|
287
|
-
'Content-Type': 'application/json',
|
|
288
|
-
Authorization: 'test-access-token',
|
|
289
|
-
},
|
|
290
|
-
body: JSON.stringify({
|
|
291
|
-
operations: [['custom_json', {
|
|
292
|
-
required_auths: [],
|
|
293
|
-
required_posting_auths: [''],
|
|
294
|
-
id: 'follow',
|
|
295
|
-
json: JSON.stringify(['follow', {
|
|
296
|
-
follower: '',
|
|
297
|
-
following: '',
|
|
298
|
-
what: []
|
|
299
|
-
}])
|
|
300
|
-
}]]
|
|
301
|
-
})
|
|
302
|
-
})
|
|
303
|
-
expect(response).toBeTruthy()
|
|
304
|
-
})
|
|
305
|
-
|
|
306
|
-
it('should send request and return promise on follow call', async function () {
|
|
307
|
-
const response = await instance.follow('', '')
|
|
308
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
|
|
309
|
-
method: 'POST',
|
|
310
|
-
headers: {
|
|
311
|
-
Accept: 'application/json, text/plain, */*',
|
|
312
|
-
'Content-Type': 'application/json',
|
|
313
|
-
Authorization: 'test-access-token',
|
|
314
|
-
},
|
|
315
|
-
body: JSON.stringify({
|
|
316
|
-
operations: [['custom_json', {
|
|
317
|
-
required_auths: [],
|
|
318
|
-
required_posting_auths: [''],
|
|
319
|
-
id: 'follow',
|
|
320
|
-
json: JSON.stringify(['follow', {
|
|
321
|
-
follower: '',
|
|
322
|
-
following: '',
|
|
323
|
-
what: ['blog']
|
|
324
|
-
}])
|
|
325
|
-
}]]
|
|
326
|
-
})
|
|
327
|
-
})
|
|
328
|
-
expect(response).toBeTruthy()
|
|
329
|
-
})
|
|
330
|
-
|
|
331
|
-
it('should send request and return promise on reblog call', async function () {
|
|
332
|
-
const response = await instance.reblog('', '', '')
|
|
333
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
|
|
334
|
-
method: 'POST',
|
|
335
|
-
headers: {
|
|
336
|
-
Accept: 'application/json, text/plain, */*',
|
|
337
|
-
'Content-Type': 'application/json',
|
|
338
|
-
Authorization: 'test-access-token',
|
|
339
|
-
},
|
|
340
|
-
body: JSON.stringify({
|
|
341
|
-
operations: [['custom_json', {
|
|
342
|
-
required_auths: [],
|
|
343
|
-
required_posting_auths: [''],
|
|
344
|
-
id: 'follow',
|
|
345
|
-
json: JSON.stringify(['reblog', {
|
|
346
|
-
account: '',
|
|
347
|
-
author: '',
|
|
348
|
-
permlink: ''
|
|
349
|
-
}])
|
|
350
|
-
}]]
|
|
351
|
-
})
|
|
352
|
-
})
|
|
353
|
-
expect(response).toBeTruthy()
|
|
354
|
-
})
|
|
355
|
-
|
|
356
|
-
it('should send request and return promise on deleteComment call', async function () {
|
|
357
|
-
const response = await instance.deleteComment('', '')
|
|
358
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
|
|
359
|
-
method: 'POST',
|
|
360
|
-
headers: {
|
|
361
|
-
Accept: 'application/json, text/plain, */*',
|
|
362
|
-
'Content-Type': 'application/json',
|
|
363
|
-
Authorization: 'test-access-token',
|
|
364
|
-
},
|
|
365
|
-
body: JSON.stringify({
|
|
366
|
-
operations: [['delete_comment', {
|
|
367
|
-
author: '',
|
|
368
|
-
permlink: ''
|
|
369
|
-
}]]
|
|
370
|
-
})
|
|
371
|
-
})
|
|
372
|
-
expect(response).toBeTruthy()
|
|
373
|
-
})
|
|
374
|
-
|
|
375
|
-
it('should send request and return promise on comment call', async function () {
|
|
376
|
-
let response = await instance.comment('', '', '', '', '', {}, {})
|
|
377
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
|
|
378
|
-
method: 'POST',
|
|
379
|
-
headers: {
|
|
380
|
-
Accept: 'application/json, text/plain, */*',
|
|
381
|
-
'Content-Type': 'application/json',
|
|
382
|
-
Authorization: 'test-access-token',
|
|
383
|
-
},
|
|
384
|
-
body: JSON.stringify({
|
|
385
|
-
operations: [['comment', {
|
|
386
|
-
parent_author: '',
|
|
387
|
-
parent_permlink: '',
|
|
388
|
-
author: '',
|
|
389
|
-
permlink: '',
|
|
390
|
-
title: '',
|
|
391
|
-
body: {},
|
|
392
|
-
json_metadata: JSON.stringify({})
|
|
393
|
-
}]]
|
|
394
|
-
})
|
|
395
|
-
})
|
|
396
|
-
expect(response).toBeTruthy()
|
|
397
|
-
|
|
398
|
-
response = await instance.comment('', '', '', '', '', {}, 'meta')
|
|
399
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
|
|
400
|
-
method: 'POST',
|
|
401
|
-
headers: {
|
|
402
|
-
Accept: 'application/json, text/plain, */*',
|
|
403
|
-
'Content-Type': 'application/json',
|
|
404
|
-
Authorization: 'test-access-token',
|
|
405
|
-
},
|
|
406
|
-
body: JSON.stringify({
|
|
407
|
-
operations: [['comment', {
|
|
408
|
-
parent_author: '',
|
|
409
|
-
parent_permlink: '',
|
|
410
|
-
author: '',
|
|
411
|
-
permlink: '',
|
|
412
|
-
title: '',
|
|
413
|
-
body: {},
|
|
414
|
-
json_metadata: 'meta'
|
|
415
|
-
}]]
|
|
416
|
-
})
|
|
417
|
-
})
|
|
418
|
-
expect(response).toBeTruthy()
|
|
419
|
-
})
|
|
420
|
-
|
|
421
|
-
it('should send request and return promise on vote call', async function () {
|
|
422
|
-
const response = await instance.vote('', '', '', 0)
|
|
423
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/broadcast`,{
|
|
424
|
-
method: 'POST',
|
|
425
|
-
headers: {
|
|
426
|
-
Accept: 'application/json, text/plain, */*',
|
|
427
|
-
'Content-Type': 'application/json',
|
|
428
|
-
Authorization: 'test-access-token',
|
|
429
|
-
},
|
|
430
|
-
body: JSON.stringify({
|
|
431
|
-
operations: [['vote', {
|
|
432
|
-
voter: '',
|
|
433
|
-
author: '',
|
|
434
|
-
permlink: '',
|
|
435
|
-
weight: 0
|
|
436
|
-
}]]
|
|
437
|
-
})
|
|
438
|
-
})
|
|
439
|
-
expect(response).toBeTruthy()
|
|
440
|
-
})
|
|
441
|
-
|
|
442
|
-
it('should send request and return promise on me call', async function () {
|
|
443
|
-
const response = await instance.me()
|
|
444
|
-
expect(crossFetch.fetch).toHaveBeenCalledWith(`${instance.apiURL}/api/me`,{
|
|
445
|
-
method: 'POST',
|
|
446
|
-
headers: {
|
|
447
|
-
Accept: 'application/json, text/plain, */*',
|
|
448
|
-
'Content-Type': 'application/json',
|
|
449
|
-
Authorization: 'test-access-token',
|
|
450
|
-
},
|
|
451
|
-
body: JSON.stringify({})
|
|
452
|
-
})
|
|
453
|
-
expect(response).toBeTruthy()
|
|
454
|
-
})
|
|
455
|
-
})
|