-
Notifications
You must be signed in to change notification settings - Fork 386
Expand file tree
/
Copy pathtest-connection-notify-utf8accept.js
More file actions
66 lines (63 loc) · 1.3 KB
/
test-connection-notify-utf8accept.js
File metadata and controls
66 lines (63 loc) · 1.3 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var assert = require('assert'),
net = require('net'),
Imap = require('../lib/Connection'),
result;
var CRLF = '\r\n';
var RESPONSES = [
['* CAPABILITY IMAP4rev1',
'A0 OK Thats all she wrote!',
''
].join(CRLF),
['* CAPABILITY IMAP4rev1 ENABLE NOTIFY',
'A1 OK authenticated (Success)',
''
].join(CRLF),
['* ENABLED',
'A2 OK Success',
''
].join(CRLF),
['A3 OK Success',
''
].join(CRLF),
['* LIST (\\Noselect) "/" "/"',
'* LIST () "/" "भारत"',
'* LIST () "/" "&-"',
'A4 OK Success',
''
].join(CRLF),
['A5 OK Success',
''
].join(CRLF)
];
var srv = net.createServer(function(sock) {
sock.write('* OK asdf\r\n');
var buf = '', lines;
sock.on('data', function(data) {
buf += data.toString('utf8');
if (buf.indexOf(CRLF) > -1) {
lines = buf.split(CRLF);
buf = lines.pop();
lines.forEach(function() {
sock.write(RESPONSES.shift());
});
}
});
});
srv.listen(0, '127.0.0.1', function() {
var port = srv.address().port;
var imap = new Imap({
user: 'foo',
password: 'bar',
host: '127.0.0.1',
port: port,
keepalive: false,
debug: function(info) {
console.log('Debug:', info);
}
});
imap.on('ready', function() {
srv.close();
imap.end();
});
imap.connect();
});