forked from xmppjs/xmpp.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
38 lines (29 loc) · 811 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
"use strict";
const test = require("ava");
const _reconnect = require(".");
const EventEmitter = require("events");
test("it schedule a reconnect when disconnect is emitted", (t) => {
const entity = new EventEmitter();
const reconnect = _reconnect({ entity });
reconnect.scheduleReconnect = () => {
t.pass();
};
entity.emit("disconnect");
});
test("#reconnect", async (t) => {
const entity = new EventEmitter();
const reconnect = _reconnect({ entity });
entity.options = {
service: "service",
lang: "lang",
domain: "domain",
};
entity.connect = (service) => {
t.is(service, entity.options.service);
};
entity.open = ({ domain, lang }) => {
t.is(domain, entity.options.domain);
t.is(lang, entity.options.lang);
};
await reconnect.reconnect();
});