From 255081192ec8cc3a887f69dc14ba38cfee1b5751 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Fri, 8 Jun 2012 17:07:01 +1000 Subject: [PATCH] assertion fixed --- test/connect.js | 52 +++++++++++++++++++++------------------ test/core-CreateWindow.js | 3 ++- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/test/connect.js b/test/connect.js index f928aad..6c7a2b4 100644 --- a/test/connect.js +++ b/test/connect.js @@ -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(); + } }); }); diff --git a/test/core-CreateWindow.js b/test/core-CreateWindow.js index f3ea8d8..8dabaa0 100644 --- a/test/core-CreateWindow.js +++ b/test/core-CreateWindow.js @@ -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(); }); });