diff --git a/packages/stream-management/README.md b/packages/stream-management/README.md index d6bb4185..8bb8bbd5 100644 --- a/packages/stream-management/README.md +++ b/packages/stream-management/README.md @@ -24,9 +24,9 @@ Indicates that the connection was resumed. When that happens the `online` event const xmpp = client(...); const {streamManagement} = xmpp; -streamManagement.on('resumed', ()) => { +streamManagement.on('resumed', () => { console.log("session resumed"); -} +}); ``` ### fail @@ -37,9 +37,9 @@ Indicates that a stanza failed to send to the server and will not be retried. const xmpp = client(...); const {streamManagement} = xmpp; -streamManagement.on('fail', (stanza)) => { +streamManagement.on('fail', (stanza) => { console.log("fail to send", stanza.toString()); -} +}); ``` ### ack @@ -50,9 +50,9 @@ Indicates that a stanza has been acknowledged by the server. const xmpp = client(...); const {streamManagement} = xmpp; -streamManagement.on('ack', (stanza)) => { +streamManagement.on('ack', (stanza) => { console.log("stanza acknowledge by the server", stanza.toString()); -} +}); ``` ## References diff --git a/packages/stream-management/stream-features.test.js b/packages/stream-management/stream-features.test.js index 3eefbbe9..4728a1a1 100644 --- a/packages/stream-management/stream-features.test.js +++ b/packages/stream-management/stream-features.test.js @@ -131,30 +131,11 @@ test("enable - failed", async () => { test("stanza ack", async () => { const { entity } = mockClient(); - entity.mockInput( - - - , - ); - - expect(await entity.catchOutgoing()).toEqual( - , - ); - - entity.mockInput( - , - ); - - await tick(); + entity.streamManagement.enabled = true; expect(entity.streamManagement.outbound).toBe(0); expect(entity.streamManagement.outbound_q).toBeEmpty(); - expect(entity.streamManagement.enabled).toBe(true); + // expect(entity.streamManagement.enabled).toBe(true); await entity.send(); diff --git a/test/stream-management.test.js b/test/stream-management.test.js index fa5e055a..3033ded8 100644 --- a/test/stream-management.test.js +++ b/test/stream-management.test.js @@ -77,6 +77,8 @@ test("client retry stanzas", async () => { ), stamp: datetime(), }); + // Do not close the stream so that stream resumption can happen + await xmpp._closeSocket(); await xmpp.disconnect(); const el = await promise_ack; @@ -101,6 +103,7 @@ test( , ); + // Pretend we don't receive the ack by removing event listeners // on the socket xmpp._detachSocket();