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!
This commit is contained in:
Naz 2022-09-06 17:51:49 +08:00
parent a96a7340c0
commit d0c45cbe9e
No known key found for this signature in database

View File

@ -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 () { it('Loads registered adapters in the order defined by the paths', function () {
const pathsToAdapters = [ const pathsToAdapters = [
'first/path', 'first/path',