-
Notifications
You must be signed in to change notification settings - Fork 378
/
Copy pathtest.js
39 lines (31 loc) · 995 Bytes
/
test.js
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
import { mockClient, promise, timeout } from "@xmpp/test";
import sessionEstablishment from "./index.js";
test("mandatory", async () => {
const { entity } = mockClient();
sessionEstablishment(entity);
entity.mockInput(
<features xmlns="http://etherx.jabber.org/streams">
<session xmlns="urn:ietf:params:xml:ns:xmpp-session" />
</features>,
);
entity.scheduleIncomingResult();
const child = await entity.catchOutgoingSet();
expect(child).toEqual(
<session xmlns="urn:ietf:params:xml:ns:xmpp-session" />,
);
});
test("optional", async () => {
const { entity } = mockClient();
sessionEstablishment(entity);
entity.mockInput(
<features xmlns="http://etherx.jabber.org/streams">
<session xmlns="urn:ietf:params:xml:ns:xmpp-session">
<optional />
</session>
</features>,
);
const promiseSend = promise(entity, "send");
await timeout(promiseSend, 0).catch((err) => {
expect(err.name).toBe("TimeoutError");
});
});