diff --git a/index.js b/index.js index f5cc7f64e0..07bb1f7222 100644 --- a/index.js +++ b/index.js @@ -16,7 +16,19 @@ function isDisposable(email) { return disposable.indexOf(domain) !== -1; } +// Return a copy of the full list domains serving free email accounts, including disposable email accounts +function freeList() { + return free.slice(); +} + +// Return a copy of the full list of domains serving disposable email accounts +function disposableList() { + return disposable.slice(); +} + module.exports = { isFree: isFree, - isDisposable: isDisposable + isDisposable: isDisposable, + freeList: freeList, + disposableList: disposableList }; diff --git a/test/test.js b/test/test.js index 83efd41a49..cf117802c7 100644 --- a/test/test.js +++ b/test/test.js @@ -30,3 +30,33 @@ test('gmail.com should not be disposable', function(t) { t.plan(1); t.equal(freemail.isDisposable('smith@gmail.com'), false); }); + +test('freeList() should return an array', function(t) { + t.plan(1); + t.equal(Array.isArray(freemail.freeList()), true); +}); + +test('freeList() should return an array containing gmail.com', function(t) { + t.plan(1); + t.notEqual(freemail.freeList().indexOf('gmail.com'), -1); +}); + +test('freeList() should return an array containing mailinater.com', function(t) { + t.plan(1); + t.notEqual(freemail.freeList().indexOf('mailinater.com'), -1); +}); + +test('disposableList() should return an array', function(t) { + t.plan(1); + t.equal(Array.isArray(freemail.disposableList()), true); +}); + +test('disposableList() should return an array containing mailinater.com', function(t) { + t.plan(1); + t.notEqual(freemail.disposableList().indexOf('mailinater.com'), -1); +}); + +test('disposableList() should return an array not containing gmail.com', function(t) { + t.plan(1); + t.equal(freemail.disposableList().indexOf('gmail.com'), -1); +});