mirror of
https://github.com/danbulant/node-x11
synced 2026-07-03 02:00:44 +00:00
assertion fixed
This commit is contained in:
parent
5dec4c29b7
commit
255081192e
2 changed files with 30 additions and 25 deletions
|
|
@ -3,43 +3,47 @@ var x11 = require('../lib/x11');
|
||||||
var should = require('should');
|
var should = require('should');
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
|
||||||
describe("Client", function() {
|
describe('Client', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
var display;
|
||||||
|
beforeEach(function(done) {
|
||||||
|
var client = x11.createClient(function(dpy) {
|
||||||
|
display=dpy;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
client.on('error', function(err) { done(err); });
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
it('calls first createClient parameter with display object', function(done) {
|
||||||
});
|
|
||||||
|
|
||||||
it("calls first createClient parameter with display object", function(done) {
|
|
||||||
var client = x11.createClient(function(display) {
|
|
||||||
should.exist(display);
|
should.exist(display);
|
||||||
should.exist(display.screen);
|
should.exist(display.screen);
|
||||||
should.exist(display.screen[0]);
|
should.exist(display.screen[0]);
|
||||||
should.exist(display.screen[0].root);
|
should.exist(display.screen[0].root);
|
||||||
should.exist(display.major);
|
should.exist(display.major);
|
||||||
done();
|
done();
|
||||||
});
|
|
||||||
client.on('error', function(err) { done(err); });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("throws error if $DISPLAY is bogus", function(done) {
|
it('uses display variable from parameter if present ignoring anvironment $DISPLAY', function(done) {
|
||||||
try {
|
|
||||||
var client = x11.createClient(function(display) {
|
|
||||||
done("Should not reach here");
|
|
||||||
}, "BOGUS DISPLAY");
|
|
||||||
client.on('error', function(err) { done(); });
|
|
||||||
} catch(err) {
|
|
||||||
assert(err && err.message == "Cannot parse display");
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it("uses display variable from parameter if present ignoring anvironment $DISPLAY", function(done) {
|
|
||||||
var disp = process.env.DISPLAY;
|
var disp = process.env.DISPLAY;
|
||||||
process.env.DISPLAY = "BOGUS DISPLAY";
|
process.env.DISPLAY = 'BOGUS DISPLAY';
|
||||||
var client = x11.createClient(function(display) {
|
var client = x11.createClient(function(display) {
|
||||||
done();
|
done();
|
||||||
}, disp);
|
}, disp);
|
||||||
|
process.env.DISPLAY=disp;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('throws error if $DISPLAY is bogus', function(done) {
|
||||||
|
try {
|
||||||
|
assert.throws(function() {
|
||||||
|
var client = x11.createClient(function(display) {
|
||||||
|
done('Should not reach here');
|
||||||
|
}, 'BOGUS DISPLAY');
|
||||||
|
client.on('error', function(err) { done(); });
|
||||||
|
}, /Cannot parse display/);
|
||||||
|
done();
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e);
|
||||||
|
done();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,8 @@ describe('CreateWindow request', function() {
|
||||||
X.QueryTree(display.screen[0].root, function(err, list) {
|
X.QueryTree(display.screen[0].root, function(err, list) {
|
||||||
if (err)
|
if (err)
|
||||||
done(err);
|
done(err);
|
||||||
assert(list.children.indexOf(wid) != -1, 'can\'t find created window');
|
var pos = list.children.indexOf(wid);
|
||||||
|
assert.notEqual(pos, -1, 'can\'t find created window');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue