Skip to content

Commit

Permalink
Some linting
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Sep 1, 2020
1 parent 76f4344 commit 2de444c
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions spec/Network.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
describe('Network protocol', () => {
let runtime = null;
let client = null;
before(() => runtime = new direct.Runtime({
permissions: {
foo: ['protocol:graph', 'protocol:network'],
},
baseDir,
}));
before(() => {
runtime = new direct.Runtime({
permissions: {
foo: ['protocol:graph', 'protocol:network'],
},
baseDir,
});
});
beforeEach(() => {
client = new direct.Client(runtime);
return client.connect();
client.connect();
});
afterEach(() => {
if (!client) { return; }
client.removeAllListeners('message');
client.disconnect();
return client = null;
client = null;
});

describe('defining a graph', () => it('should succeed', (done) => {
client.on('error', (err) => done(err));
client.on('message', (msg) => {
if (msg.command === 'error') {
return done(msg.payload);
done(msg.payload);
return;
}
if (msg.command !== 'addinitial') { return; }
chai.expect(msg.payload.src.data).to.equal('Hello, world!');
return done();
done();
});
client.send('graph', 'clear', {
id: 'bar',
Expand Down Expand Up @@ -57,7 +60,7 @@ describe('Network protocol', () => {
graph: 'bar',
secret: 'foo',
});
return client.send('graph', 'addinitial', {
client.send('graph', 'addinitial', {
src: {
data: 'Hello, world!',
},
Expand All @@ -69,7 +72,7 @@ describe('Network protocol', () => {
secret: 'foo',
});
}));
return describe('starting the network', () => {
describe('starting the network', () => {
it('should process the nodes and stop when it completes', (done) => {
const expects = [
'started',
Expand All @@ -80,29 +83,32 @@ describe('Network protocol', () => {
client.on('error', (err) => done(err));
client.on('message', (msg) => {
if (msg.command === 'error') {
return done(msg.payload);
done(msg.payload);
return;
}
if (msg.protocol !== 'network') { return; }
chai.expect(msg.protocol).to.equal('network');
chai.expect(msg.command).to.equal(expects.shift());
if (!expects.length) { return done(); }
if (!expects.length) {
done();
}
});
return client.send('network', 'start', {
client.send('network', 'start', {
graph: 'bar',
secret: 'foo',
});
});
return it('should provide a "finished" status', (done) => {
it('should provide a "finished" status', (done) => {
client.on('error', (err) => done(err));
client.on('message', (msg) => {
chai.expect(msg.protocol).to.equal('network');
chai.expect(msg.command).to.equal('status');
chai.expect(msg.payload.graph).to.equal('bar');
chai.expect(msg.payload.running).to.equal(false);
chai.expect(msg.payload.started).to.equal(false);
return done();
done();
});
return client.send('network', 'getstatus', {
client.send('network', 'getstatus', {
graph: 'bar',
secret: 'foo',
});
Expand Down

0 comments on commit 2de444c

Please sign in to comment.