This repository has been archived by the owner on Apr 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
97 lines (57 loc) · 1.82 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const assert = require('chai').assert;
const mute = require('./src/plugin.js');
const ChatEngine = require('./node_modules/chat-engine/src/index.js');
let pluginchat;
let CE;
describe('config', function() {
it('should be configured', function() {
CE = ChatEngine.create({
publishKey: 'pub-c-01491c54-379f-4d4a-b20b-9a03c24447c7',
subscribeKey: 'sub-c-eaf4a984-4356-11e8-91e7-8ad1b2d46395',
});
assert.isOk(CE);
});
});
describe('connect', function() {
it('should be identified as new user', function(done) {
this.timeout(10000);
CE.connect('robot-tester' + new Date().getTime(), {works: true}, 'auth-key');
CE.on('$.ready', (data) => {
assert.isObject(data.me);
done();
})
});
});
describe('plugins', function() {
it('should be created', function() {
pluginchat = new CE.Chat('pluginchat' + new Date().getTime());
pluginchat2 = new CE.Chat('pluginchat' + new Date().getTime());
pluginchat.plugin(mute({}));
pluginchat2.plugin(mute({}));
pluginchat.on('$.ready', () => {
done();
});
});
it('should be muted', function(done) {
this.timeout(30000);
pluginchat.muter.mute(CE.me);
pluginchat.once('message2', (payload) => {
assert.fail();
});
pluginchat.once('$.muter.eventRejected', (payload) => {
done();
});
setInterval(() => {
pluginchat.emit('message2', {
text: 'test'
});
}, 1000);
});
it('should not be muted', function(done) {
pluginchat2.on('message2', (payload) => {
assert.fail();
});
pluginchat2.emit('message2', 'test');
done();
});
});