Skip to content

Commit 86524b4

Browse files
committed
tests: add tests for debug array option
1 parent 5658422 commit 86524b4

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var assert = require('assert');
2+
var common = require('../../common');
3+
var connection = common.createConnection({
4+
debug : ['OkPacket', 'ComPingPacket'],
5+
port : common.fakeServerPort
6+
});
7+
8+
var server = common.createFakeServer();
9+
10+
server.listen(common.fakeServerPort, function (err) {
11+
assert.ifError(err);
12+
13+
var messages = [];
14+
15+
console.log = function (str) {
16+
if (typeof str === 'string' && str.length !== 0) {
17+
messages.push(str);
18+
}
19+
};
20+
21+
connection.ping(function (err) {
22+
assert.ifError(err);
23+
assert.equal(messages.length, 3);
24+
assert.deepEqual(messages, [
25+
'<-- OkPacket',
26+
'--> ComPingPacket',
27+
'<-- OkPacket'
28+
]);
29+
30+
connection.destroy();
31+
server.destroy();
32+
});
33+
});

0 commit comments

Comments
 (0)