Filter out blank emails

This commit is contained in:
Blade Barringer
2015-08-21 21:39:04 -05:00
parent 59dc0cdb4f
commit 07b9b35234
2 changed files with 39 additions and 4 deletions

View File

@@ -51,8 +51,10 @@ describe('Invite to Group Controller', function() {
context('email', function() {
it('invites user with emails', function() {
scope.emails[0].name = 'Luigi';
scope.emails[0].email = 'mario_bro@themushroomkingdom.com';
scope.emails = [
{name: 'Luigi', email: 'mario_bro@themushroomkingdom.com'},
{name: 'Mario', email: 'mario@tmk.com'}
];
scope.inviteNewUsers('email');
expect(groups.Group.invite).to.be.calledOnce;
@@ -60,7 +62,10 @@ describe('Invite to Group Controller', function() {
gid: scope.group._id,
}, {
inviter: user.profile.name,
emails: [{name: 'Luigi', email: 'mario_bro@themushroomkingdom.com'},{name: '', email: ''}]
emails: [
{name: 'Luigi', email: 'mario_bro@themushroomkingdom.com'},
{name: 'Mario', email: 'mario@tmk.com'}
]
});
});
@@ -74,6 +79,26 @@ describe('Invite to Group Controller', function() {
expect(scope.emails).to.eql([{name:'', email: ''},{name:'', email: ''}]);
});
it('filters out blank email inputs', function() {
scope.emails = [
{name: 'Luigi', email: 'mario_bro@themushroomkingdom.com'},
{name: 'Toad', email: ''},
{name: 'Mario', email: 'mario@tmk.com'}
];
scope.inviteNewUsers('email');
expect(groups.Group.invite).to.be.calledOnce;
expect(groups.Group.invite).to.be.calledWith({
gid: scope.group._id,
}, {
inviter: user.profile.name,
emails: [
{name: 'Luigi', email: 'mario_bro@themushroomkingdom.com'},
{name: 'Mario', email: 'mario@tmk.com'}
]
});
});
});
context('uuid', function() {