@@ -42,7 +42,9 @@ describe('Dm3Sdk', () => {
42
42
ethers . Wallet . createRandom ( ) ,
43
43
'http://localhost:3000' ,
44
44
) ;
45
+ } ) ;
45
46
47
+ beforeAll ( ( ) => {
46
48
axiosMock = new MockAdapter ( axios ) ;
47
49
48
50
//Mock BackendConnector HttpRequests
@@ -102,9 +104,8 @@ describe('Dm3Sdk', () => {
102
104
} ) ;
103
105
104
106
await dm3 . conversations . addConversation ( 'bob.eth' ) ;
105
- const c = dm3 . conversations . list ;
106
- expect ( c . length ) . toBe ( 1 ) ;
107
- expect ( c [ 0 ] . contact . name ) . toBe ( 'bob.eth' ) ;
107
+ expect ( dm3 . conversations . list . length ) . toBe ( 1 ) ;
108
+ expect ( dm3 . conversations . list [ 0 ] . contact . name ) . toBe ( 'bob.eth' ) ;
108
109
} ) ;
109
110
it ( 'can multiple conversations to the contact list' , async ( ) => {
110
111
const mockTldResolver = {
@@ -156,12 +157,10 @@ describe('Dm3Sdk', () => {
156
157
157
158
await dm3 . conversations . addConversation ( 'bob.eth' ) ;
158
159
await dm3 . conversations . addConversation ( 'karl.eth' ) ;
159
- const c = dm3 . conversations . list ;
160
- dm3 ;
161
- console . log ( c ) ;
162
- expect ( c . length ) . toBe ( 2 ) ;
163
- expect ( c [ 0 ] . contact . name ) . toBe ( 'bob.eth' ) ;
164
- expect ( c [ 1 ] . contact . name ) . toBe ( 'karl.eth' ) ;
160
+
161
+ expect ( dm3 . conversations . list . length ) . toBe ( 2 ) ;
162
+ expect ( dm3 . conversations . list [ 0 ] . contact . name ) . toBe ( 'bob.eth' ) ;
163
+ expect ( dm3 . conversations . list [ 1 ] . contact . name ) . toBe ( 'karl.eth' ) ;
165
164
} ) ;
166
165
it ( 'dont add duplicate conversations' , async ( ) => {
167
166
const mockTldResolver = {
@@ -192,9 +191,8 @@ describe('Dm3Sdk', () => {
192
191
193
192
await dm3 . conversations . addConversation ( 'bob.eth' ) ;
194
193
await dm3 . conversations . addConversation ( 'bob.eth' ) ;
195
- const c = dm3 . conversations . list ;
196
- expect ( c . length ) . toBe ( 1 ) ;
197
- expect ( c [ 0 ] . contact . name ) . toBe ( 'bob.eth' ) ;
194
+ expect ( dm3 . conversations . list . length ) . toBe ( 1 ) ;
195
+ expect ( dm3 . conversations . list [ 0 ] . contact . name ) . toBe ( 'bob.eth' ) ;
198
196
} ) ;
199
197
} ) ;
200
198
@@ -231,12 +229,25 @@ describe('Dm3Sdk', () => {
231
229
232
230
const msg1 = await msgFactory . createMessage ( 'Hi' ) ;
233
231
234
- const c = await dm3 . conversations . addConversation ( 'bob.eth' ) ;
235
- expect ( c ?. messages . list ( ) . length ) . toBe ( 0 ) ;
236
- await c ?. messages . addMessage ( 'bob.eth' , msg1 ) ;
237
-
238
- expect ( c ?. messages . list ( ) . length ) . toBe ( 1 ) ;
239
- expect ( c ?. messages . list ( ) [ 0 ] . envelop . message . message ) . toBe ( 'Hi' ) ;
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' ) ;
240
251
} ) ;
241
252
it ( 'can send a message' , async ( ) => {
242
253
const mockTldResolver = {
@@ -266,13 +277,26 @@ describe('Dm3Sdk', () => {
266
277
accountAddress : alice . address ,
267
278
} ) ;
268
279
269
- const c = await dm3 . conversations . addConversation ( 'bob.eth' ) ;
270
- expect ( c ?. messages . list ( ) . length ) . toBe ( 0 ) ;
271
-
272
- await c ?. messages . sendMessage ( 'Hi' ) ;
273
-
274
- expect ( c ?. messages . list ( ) . length ) . toBe ( 1 ) ;
275
- expect ( c ?. messages . list ( ) [ 0 ] . envelop . message . message ) . toBe ( 'Hi' ) ;
280
+ expect (
281
+ (
282
+ await dm3 . conversations . addConversation ( 'bob.eth' )
283
+ ) ?. messages . list ( ) . length ,
284
+ ) . toBe ( 0 ) ;
285
+
286
+ await (
287
+ await dm3 . conversations . addConversation ( 'bob.eth' )
288
+ ) ?. messages . sendMessage ( 'Hi' ) ;
289
+
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' ) ;
276
300
} ) ;
277
301
} ) ;
278
302
} ) ;
0 commit comments