Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide accessors for the underling arrays of domains #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
30 changes: 30 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,33 @@ test('gmail.com should not be disposable', function(t) {
t.plan(1);
t.equal(freemail.isDisposable('[email protected]'), 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);
});