@@ -42,9 +42,6 @@ describe('Dm3Sdk', () => {
42
42
ethers . Wallet . createRandom ( ) ,
43
43
'http://localhost:3000' ,
44
44
) ;
45
- } ) ;
46
-
47
- beforeAll ( ( ) => {
48
45
axiosMock = new MockAdapter ( axios ) ;
49
46
50
47
//Mock BackendConnector HttpRequests
@@ -197,58 +194,6 @@ describe('Dm3Sdk', () => {
197
194
} ) ;
198
195
199
196
describe ( 'Messages' , ( ) => {
200
- it ( 'can send a message' , async ( ) => {
201
- const mockTldResolver = {
202
- resolveTLDtoAlias : async ( ) =>
203
- `${ normalizeEnsName ( bob . address ) } .addr.test` ,
204
- resolveAliasToTLD : async ( ) => 'bob.eth' ,
205
- } as unknown as ITLDResolver ;
206
-
207
- const mockConfig : Dm3SdkConfig = {
208
- mainnetProvider : { } as ethers . providers . JsonRpcProvider ,
209
- storageApi : {
210
- addConversation : async ( ) => { } ,
211
- addMessage : async ( ) => { } ,
212
- } as unknown as StorageAPI ,
213
- nonce : '1' ,
214
- defaultDeliveryService : 'test.io' ,
215
- addressEnsSubdomain : '.addr.test' ,
216
- userEnsSubdomain : '.user.test' ,
217
- resolverBackendUrl : 'resolver.io' ,
218
- backendUrl : 'http://localhost:4060' ,
219
- _tld : mockTldResolver ,
220
- } ;
221
-
222
- const dm3 = await new Dm3Sdk ( mockConfig ) . login ( {
223
- profileKeys : alice . profileKeys ,
224
- profile : alice . signedUserProfile ,
225
- accountAddress : alice . address ,
226
- } ) ;
227
-
228
- const msgFactory = MockMessageFactory ( alice , bob , deliveryService ) ;
229
-
230
- const msg1 = await msgFactory . createMessage ( 'Hi' ) ;
231
-
232
- expect (
233
- (
234
- await dm3 . conversations . addConversation ( 'bob.eth' )
235
- ) ?. messages . list ( ) . length ,
236
- ) . toBe ( 0 ) ;
237
- await (
238
- await dm3 . conversations . addConversation ( 'bob.eth' )
239
- ) ?. messages . addMessage ( 'bob.eth' , msg1 ) ;
240
-
241
- expect (
242
- (
243
- await dm3 . conversations . addConversation ( 'bob.eth' )
244
- ) ?. messages . list ( ) . length ,
245
- ) . toBe ( 1 ) ;
246
- expect (
247
- (
248
- await dm3 . conversations . addConversation ( 'bob.eth' )
249
- ) ?. messages . list ( ) [ 0 ] . envelop . message . message ,
250
- ) . toBe ( 'Hi' ) ;
251
- } ) ;
252
197
it ( 'can send a message' , async ( ) => {
253
198
const mockTldResolver = {
254
199
resolveTLDtoAlias : async ( ) =>
@@ -278,25 +223,15 @@ describe('Dm3Sdk', () => {
278
223
} ) ;
279
224
280
225
expect (
281
- (
282
- await dm3 . conversations . addConversation ( 'bob.eth' )
283
- ) ?. messages . list ( ) . length ,
226
+ ( await dm3 . conversations . addConversation ( 'bob.eth' ) ) ?. messages
227
+ . list . length ,
284
228
) . toBe ( 0 ) ;
285
229
286
- await (
287
- await dm3 . conversations . addConversation ( 'bob.eth' )
288
- ) ?. messages . sendMessage ( 'Hi' ) ;
230
+ const c = await dm3 . conversations . addConversation ( 'bob.eth' ) ;
289
231
290
- expect (
291
- (
292
- await dm3 . conversations . addConversation ( 'bob.eth' )
293
- ) ?. messages . list ( ) . length ,
294
- ) . toBe ( 1 ) ;
295
- expect (
296
- (
297
- await dm3 . conversations . addConversation ( 'bob.eth' )
298
- ) ?. messages . list ( ) [ 0 ] . envelop . message . message ,
299
- ) . toBe ( 'Hi' ) ;
232
+ await c ?. messages . sendMessage ( 'Hi' ) ;
233
+ expect ( c ?. messages . list . length ) . toBe ( 1 ) ;
234
+ expect ( c ?. messages . list [ 0 ] . envelop . message . message ) . toBe ( 'Hi' ) ;
300
235
} ) ;
301
236
} ) ;
302
237
} ) ;
0 commit comments