node-x11/test/connection-utils.js
2012-07-16 19:48:03 +10:00

34 lines
906 B
JavaScript

var x11 = require('../lib/x11');
var should = require('should');
var assert = require('assert');
describe('Client', function() {
var display;
beforeEach(function(done) {
var client = x11.createClient(function(dpy) {
display=dpy;
done();
client.removeListener('error', done);
});
client.on('error', done);
});
it('should respond to ping()', function(done) {
display.client.ping(done);
});
it('should allow to enqueue requests and gracefully execute them before close()', function(done) {
var count = 0;
var pong = function(err) { if (err) return done(err); count++; }
display.client.ping(pong);
display.client.ping(pong);
display.client.ping(pong);
display.client.ping(pong);
display.client.close(function(err) {
if (err) return done(err);
assert.equal(count,4);
done();
});
})
});