From d0c45cbe9e85068ea3cc71e9a3f555a5f49bcf13 Mon Sep 17 00:00:00 2001 From: Naz Date: Tue, 6 Sep 2022 17:51:49 +0800 Subject: [PATCH] Increased adapter manager test coverage refs https://github.com/TryGhost/Toolbox/issues/384 - Boyscouting while having the context loaded. Getting to those 100% coverages one day! --- .../test/AdapterManager.test.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ghost/adapter-manager/test/AdapterManager.test.js b/ghost/adapter-manager/test/AdapterManager.test.js index 2fb65b8ae4..13affd203f 100644 --- a/ghost/adapter-manager/test/AdapterManager.test.js +++ b/ghost/adapter-manager/test/AdapterManager.test.js @@ -42,6 +42,29 @@ describe('AdapterManager', function () { } }); + it('getAdapter throws if config does not contain adapter type key', function () { + const pathsToAdapters = [ + 'first/path' + ]; + + const loadAdapterFromPath = sinon.stub(); + const adapterManager = new AdapterManager({ + loadAdapterFromPath, + pathsToAdapters + }); + + adapterManager.registerAdapter('some_other_adapter_type', BaseMailAdapter); + + try { + adapterManager.getAdapter('mail', 'custom'); + should.fail(null, null, 'Should not have created'); + } catch (err) { + should.exist(err); + should.equal(err.errorType, 'NotFoundError'); + should.equal(err.message, 'Unknown adapter type mail. Please register adapter.'); + } + }); + it('Loads registered adapters in the order defined by the paths', function () { const pathsToAdapters = [ 'first/path',