@@ -42,9 +42,6 @@ describe('Dm3Sdk', () => {
4242 ethers . Wallet . createRandom ( ) ,
4343 'http://localhost:3000' ,
4444 ) ;
45- } ) ;
46-
47- beforeAll ( ( ) => {
4845 axiosMock = new MockAdapter ( axios ) ;
4946
5047 //Mock BackendConnector HttpRequests
@@ -197,58 +194,6 @@ describe('Dm3Sdk', () => {
197194 } ) ;
198195
199196 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- } ) ;
252197 it ( 'can send a message' , async ( ) => {
253198 const mockTldResolver = {
254199 resolveTLDtoAlias : async ( ) =>
@@ -278,25 +223,15 @@ describe('Dm3Sdk', () => {
278223 } ) ;
279224
280225 expect (
281- (
282- await dm3 . conversations . addConversation ( 'bob.eth' )
283- ) ?. messages . list ( ) . length ,
226+ ( await dm3 . conversations . addConversation ( 'bob.eth' ) ) ?. messages
227+ . list . length ,
284228 ) . toBe ( 0 ) ;
285229
286- await (
287- await dm3 . conversations . addConversation ( 'bob.eth' )
288- ) ?. messages . sendMessage ( 'Hi' ) ;
230+ const c = await dm3 . conversations . addConversation ( 'bob.eth' ) ;
289231
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' ) ;
300235 } ) ;
301236 } ) ;
302237} ) ;
0 commit comments