Refactored bootstrap-socket API for testability

- this makes it much easier to stub this behaviour in tests
- also makes more sense
This commit is contained in:
Hannah Wolfe 2020-08-09 17:15:46 +01:00
parent ab291cb922
commit a01d44fa6a
3 changed files with 4 additions and 4 deletions

View File

@ -1 +1 @@
module.exports = require('./lib/connect-and-send');
module.exports = require('./lib/bootstrap-socket');

View File

@ -1,4 +1,4 @@
module.exports = (socketAddress, logging, message) => {
module.exports.connectAndSend = (socketAddress, logging, message) => {
// Very basic guard against bad calls
if (!socketAddress || !socketAddress.host || !socketAddress.port || !logging || !logging.info || !logging.warn || !message) {
return Promise.resolve();

View File

@ -2,10 +2,10 @@
// const testUtils = require('./utils');
require('./utils');
const connectAndSend = require('../lib/connect-and-send');
const bootstrapSocket = require('../lib/bootstrap-socket');
describe('Connect and send', function () {
it('Resolves a promise for a bad call', function () {
connectAndSend().should.be.fulfilled();
bootstrapSocket.connectAndSend().should.be.fulfilled();
});
});