forked from xmppjs/xmpp.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser.test.js
More file actions
46 lines (37 loc) · 1.12 KB
/
browser.test.js
File metadata and controls
46 lines (37 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { test, beforeEach, afterEach } from "node:test";
import { readFileSync } from "node:fs";
import { JSDOM } from "jsdom";
import { jid } 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";
const JID = jid(username, domain).toString();
const service = "ws://localhost:5280/xmpp-websocket";
const xmppjs = readFileSync("./packages/client/dist/xmpp.js", {
encoding: "utf8",
});
let window;
let xmpp;
beforeEach(async () => {
({ window } = new JSDOM(``, { runScripts: "dangerously" }));
const { document } = window;
const scriptEl = document.createElement("script");
scriptEl.textContent = xmppjs;
document.body.append(scriptEl);
await server.restart();
});
afterEach(async () => {
await xmpp?.stop();
});
test("client ws://", async (t) => {
xmpp = window.XMPP.client({
credentials,
service,
});
debug(xmpp);
const address = await xmpp.start();
t.assert.strictEqual(address.bare().toString(), JID);
});