node-x11/test/connection-utils.js
Santiago Gimeno 4508f9e93d Change createClient signature
- The new signature is:

  createClient(options, initCB), where
     - options is an optional object that defines different parameters such as
               display, etc.
     - initCB is an optional callback with the signature: function(err, display)
- The initCB is going to be called with an error ONLY if the connection to the X
  server fails. Further errors in the server connection will be 'emitted'.
- Update tests and test-runner.js accordingly.
- Update README.
2012-12-19 09:34:19 +01:00

38 lines
1,015 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(err, dpy) {
if (!err) {
display = dpy;
done();
client.removeListener('error', done);
} else {
done(err);
}
});
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();
});
})
});