Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('sets itself as its successor if the successors list only has one element.', done => {
peer.setSuccessor({ host: 'example.com', port: 3000 });
peer.successors = [{ host: 'foo.com', port: 3000 }];
peer.fixSuccessor();
assert.that(peer.successor).is.equalTo(peer.self);
done();
});
test('initially contains information on the endpoint of the peer.', done => {
assert.that(peer.predecessor).is.equalTo({
host: 'localhost',
port: 3000,
id: sha1('localhost:3000')
});
done();
});
});
}, (code, stdout, stderr) => {
assert.that(code).is.equalTo(0);
const messages = stdout.split('\n').
filter(line => line !== '').
map(line => JSON.parse(line));
assert.that(messages[0].level).is.equalTo('info');
assert.that(messages[0].message).is.equalTo('Application started.');
assert.that(messages[1].level).is.equalTo('error');
assert.that(messages[1].message).is.equalTo('Something, somewhere went horribly wrong...');
assert.that(stderr).is.equalTo('');
done();
});
});
test('is a function.', done => {
assert.that(handle).is.ofType('function');
done();
});
test('is an object.', done => {
assert.that(p2p).is.ofType('object');
done();
});
assert.that(paragraph).is.ofType('object');
assert.that(paragraph.host).is.equalTo('example.com');
assert.that(paragraph.pid).is.equalTo(process.pid);
assert.that(paragraph.id).is.ofType('number');
assert.that(paragraph.timestamp).is.not.undefined();
assert.that(paragraph.level).is.equalTo('info');
assert.that(paragraph.message).is.equalTo('App started.');
assert.that(paragraph.application.name).is.equalTo('flaschenpost');
assert.that(paragraph.application.version).is.not.undefined();
assert.that(paragraph.module).is.equalTo({
name: 'foo',
version: '0.0.1'
});
assert.that(paragraph.source).is.equalTo(__filename);
assert.that(paragraph.metadata).is.ofType('object');
assert.that(paragraph.metadata.name).is.equalTo('Error');
assert.that(paragraph.metadata.message).is.equalTo('Something went wrong.');
done();
});
letter.once('data', data => {
assert.that(data.level).is.equalTo('info');
assert.that(data.message).is.equalTo('foobar');
assert.that(data.application.name).is.equalTo('flaschenpost');
assert.that(data.application.version).is.not.undefined();
assert.that(data.module).is.equalTo({
name: 'foo',
version: '0.0.1'
});
done();
});
], (url, expectedUrl, done) => {
assert.that(rewrite(url, {
hostname: 'www.thenativeweb.io'
})).is.equalTo(expectedUrl);
done();
}));
letter.once('data', data => {
assert.that(data.level).is.equalTo('info');
assert.that(data.message).is.equalTo('foobar');
assert.that(data.application.name).is.equalTo('flaschenpost');
assert.that(data.application.version).is.not.undefined();
assert.that(data.module).is.equalTo({
name: 'foo',
version: '0.0.1'
});
done();
});
letter.once('data', paragraph => {
assert.that(paragraph).is.ofType('object');
assert.that(paragraph.pid).is.equalTo(process.pid);
assert.that(paragraph.id).is.ofType('number');
assert.that(paragraph.timestamp).is.not.undefined();
assert.that(paragraph.level).is.equalTo('info');
assert.that(paragraph.message).is.equalTo('App started.');
assert.that(paragraph.module).is.equalTo({
name: 'foo',
version: '0.0.1'
});
assert.that(paragraph.source).is.equalTo(__filename);
assert.that(paragraph.metadata).is.equalTo({
foo: 'bar',
metadata: {
bar: 'baz'
}
});
done();
});