Skip to content

Commit

Permalink
e2e test for stream management
Browse files Browse the repository at this point in the history
  • Loading branch information
singpolyma committed Jan 8, 2025
1 parent d689816 commit 49e0fe1
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/stream-management.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { client } from "../packages/client/index.js";
import debug from "../packages/debug/index.js";
import server from "../server/index.js";

const username = "client";
const password = "foobar";
const credentials = { username, password };
const domain = "localhost";

let xmpp;

afterEach(async () => {
await xmpp?.stop();
await server.reset();
});

test("client ack stanzas", async () => {
expect.assertions(1);

await server.enableModules(["smacks"]);
await server.restart();

xmpp = client({ credentials, service: domain });
debug(xmpp);

xmpp.streamManagement.on("ack", (el) => {
expect(el.attrs.id).toEqual("ping");
xmpp.streamManagement._teardown();
xmpp.stop();
});

await xmpp.start();
await xmpp.send(
<iq to={domain} id="ping">
<ping xmlns="urn:xmppp:ping" />
</iq>,
);
});

0 comments on commit 49e0fe1

Please sign in to comment.