assertion fixed

This commit is contained in:
Andrey Sidorov 2012-06-08 17:07:01 +10:00
parent 5dec4c29b7
commit 255081192e
2 changed files with 30 additions and 25 deletions

View file

@ -3,43 +3,47 @@ var x11 = require('../lib/x11');
var should = require('should');
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) {
var client = x11.createClient(function(display) {
it('calls first createClient parameter with display object', function(done) {
should.exist(display);
should.exist(display.screen);
should.exist(display.screen[0]);
should.exist(display.screen[0].root);
should.exist(display.major);
done();
});
client.on('error', function(err) { done(err); });
});
it("throws error if $DISPLAY is bogus", 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) {
it('uses display variable from parameter if present ignoring anvironment $DISPLAY', function(done) {
var disp = process.env.DISPLAY;
process.env.DISPLAY = "BOGUS DISPLAY";
process.env.DISPLAY = 'BOGUS DISPLAY';
var client = x11.createClient(function(display) {
done();
}, 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();
}
});
});

View file

@ -39,7 +39,8 @@ describe('CreateWindow request', function() {
X.QueryTree(display.screen[0].root, function(err, list) {
if (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();
});
});