From 1f3cf0f8011e45dc89380098db3339b8e717b2cd Mon Sep 17 00:00:00 2001 From: Gilles Dufour Date: Wed, 9 Jan 2019 16:37:37 +0100 Subject: [PATCH] Fixing server getDirectory replies --- ember.js | 28 +++++++-- package.json | 2 +- server.js | 21 ++++--- test/Server.test.js | 148 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 182 insertions(+), 17 deletions(-) create mode 100755 test/Server.test.js diff --git a/ember.js b/ember.js index f65ba78..ed0a98e 100755 --- a/ember.js +++ b/ember.js @@ -106,17 +106,15 @@ Root.prototype.addChild = function(child) { Root.prototype.encode = function(ber) { ber.startSequence(BER.APPLICATION(0)); - if(this.elements !== undefined) { ber.startSequence(BER.APPLICATION(11)); - ber.startSequence(BER.CONTEXT(0)); for(var i=0; i { + console.log("server listening"); + }); + }); + after(function() { + client.disconnect(); + server.close(); + }) + it("should receive and decode the full tree", function () { + client = new DeviceTree(LOCALHOST, PORT); + //client._debug = true; + return Promise.resolve() + .then(() => client.connect()) + .then(() => { + console.log("client connected"); + return client.getDirectory() + }) + .then(() => { + expect(client.root).toBeDefined(); + expect(client.root.elements).toBeDefined(); + expect(client.root.elements.length).toBe(1); + expect(client.root.elements[0].contents.identifier).toBe("scoreMaster"); + return client.getDirectory(client.root.elements[0]); + }) + .then(() => { + expect(client.root.elements[0].children.length).toBe(2); + return client.getDirectory(client.root.elements[0].children[0]); + }) + .then(() => { + expect(client.root.elements[0].children[0].children.length).toBe(4); + expect(client.root.elements[0].children[0].children[3].contents.identifier).toBe("author"); + }); + }); + }); +});