-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from BuckinghamAJ/dev
Grabbing Gov email in Login.gov all_emails
- Loading branch information
Showing
3 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ const User = require('../models').User | |
const authRoutes = require('../routes/auth.routes') | ||
const logger = require('../config/winston') | ||
const mocks = require('./mocks') | ||
const { getGovernmentEmail } = require('../routes/auth.routes'); | ||
|
||
const { userAcceptedCASData } = require('./test.data'); | ||
|
||
|
@@ -526,4 +527,26 @@ describe('/api/auth/', () => { | |
{'cas_userinfo':{'email-address': '[email protected]'}})).toBeFalse(); | ||
}) | ||
|
||
}) | ||
}) | ||
|
||
describe('getGovernmentEmail', () => { | ||
test('returns the first .gov email if present', () => { | ||
const emails = ['[email protected]', '[email protected]', '[email protected]']; | ||
expect(getGovernmentEmail(emails)).toBe('[email protected]'); | ||
}); | ||
|
||
test('returns the first .mil email if present', () => { | ||
const emails = ['[email protected]', '[email protected]', '[email protected]']; | ||
expect(getGovernmentEmail(emails)).toBe('[email protected]'); | ||
}); | ||
|
||
test('returns null if no .gov or .mil email is present', () => { | ||
const emails = ['[email protected]', '[email protected]']; | ||
expect(getGovernmentEmail(emails)).toBe(null); | ||
}); | ||
|
||
test('returns null if the emails array is empty', () => { | ||
const emails = []; | ||
expect(getGovernmentEmail(emails)).toBe(null); | ||
}); | ||
}); |