Exploring the interface of a mail adapter

Add some tests and demonstrate the adapter loading interface
This commit is contained in:
Drew Gross
2016-02-16 23:43:09 -08:00
committed by Florent Vilmart
parent d9f1e00345
commit 8dc37b9d30
13 changed files with 525 additions and 37 deletions

View File

@@ -1,4 +1,3 @@
export function loadAdapter(options, defaultAdapter) {
let adapter;
@@ -12,7 +11,7 @@ export function loadAdapter(options, defaultAdapter) {
adapter = options.adapter;
}
}
if (!adapter) {
adapter = defaultAdapter;
}
@@ -26,10 +25,12 @@ export function loadAdapter(options, defaultAdapter) {
}
}
// From there it's either a function or an object
// if it's an function, instanciate and pass the options
// if it's an function, instanciate and pass the options
if (typeof adapter === "function") {
var Adapter = adapter;
adapter = new Adapter(options);
}
return adapter;
}
module.exports = { loadAdapter }