From a01d44fa6a9f30df9570d2fc0f6ccc361a848859 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Sun, 9 Aug 2020 17:15:46 +0100 Subject: [PATCH] Refactored bootstrap-socket API for testability - this makes it much easier to stub this behaviour in tests - also makes more sense --- ghost/bootstrap-socket/index.js | 2 +- .../lib/{connect-and-send.js => bootstrap-socket.js} | 2 +- .../{connect-and-send.test.js => bootstrap-socket.test.js} | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename ghost/bootstrap-socket/lib/{connect-and-send.js => bootstrap-socket.js} (97%) rename ghost/bootstrap-socket/test/{connect-and-send.test.js => bootstrap-socket.test.js} (64%) diff --git a/ghost/bootstrap-socket/index.js b/ghost/bootstrap-socket/index.js index 1b27284fac..d00b0e943a 100644 --- a/ghost/bootstrap-socket/index.js +++ b/ghost/bootstrap-socket/index.js @@ -1 +1 @@ -module.exports = require('./lib/connect-and-send'); +module.exports = require('./lib/bootstrap-socket'); diff --git a/ghost/bootstrap-socket/lib/connect-and-send.js b/ghost/bootstrap-socket/lib/bootstrap-socket.js similarity index 97% rename from ghost/bootstrap-socket/lib/connect-and-send.js rename to ghost/bootstrap-socket/lib/bootstrap-socket.js index 66fc1cc5cd..db66145395 100644 --- a/ghost/bootstrap-socket/lib/connect-and-send.js +++ b/ghost/bootstrap-socket/lib/bootstrap-socket.js @@ -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(); diff --git a/ghost/bootstrap-socket/test/connect-and-send.test.js b/ghost/bootstrap-socket/test/bootstrap-socket.test.js similarity index 64% rename from ghost/bootstrap-socket/test/connect-and-send.test.js rename to ghost/bootstrap-socket/test/bootstrap-socket.test.js index b7cbff9c86..eda17b5ec3 100644 --- a/ghost/bootstrap-socket/test/connect-and-send.test.js +++ b/ghost/bootstrap-socket/test/bootstrap-socket.test.js @@ -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(); }); });