node-x11/test/core-KillKlient.js
Antti Korpi ed27aa84ff Fix 'root' deprecation warning
This would previously be printed in part of the test log:

    (node:1628) [DEP0016] DeprecationWarning: 'root' is deprecated, use 'global'

Apparently, the global object was once called root, and this assignment
didn't have a `var`, so it was actually setting the global object.

I do wonder why that didn't break anything, but this is clearly what was
intended.
2018-01-23 22:35:49 +01:00

48 lines
1.3 KiB
JavaScript

var x11 = require('../lib');
var should = require('should');
var assert = require('assert');
describe('KillKlient request', function() {
var display;
var X;
beforeEach(function(done) {
var client = x11.createClient(function(err, dpy) {
should.not.exist(err);
display = dpy;
X = display.client;
var root = display.screen[0].root;
var eventMask = x11.eventMask.SubstructureNotify;
X.ChangeWindowAttributes(root, { eventMask: eventMask });
done();
});
client.on('error', done);
});
afterEach(function(done) {
X.on('end', done);
X.terminate();
});
it('should exist as client member', function() {
should.exist(X.KillKlient);
assert.equal(typeof X.KillKlient, 'function');
});
it('should terminate other client connection', function(done) {
x11.createClient(function(err, dpy) {
should.not.exist(err);
var otherclient = dpy.client;
var wnd = otherclient.AllocID();
X.once('event', function(ev) {
ev.name.should.equal('CreateNotify');
ev.wid.should.equal(wnd);
X.KillKlient(wnd);
});
otherclient.CreateWindow(wnd, dpy.screen[0].root, 0, 0, 1, 1);
otherclient.on('end', done);
});
});
});