-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
95 additions
and
82 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
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ const auth = require('../../../controllers/auth') | |
const helpers = require('./../../helpers') | ||
const nock = require('nock') | ||
const Staticman = require('./../../../lib/Staticman') | ||
const User = require('../../../lib/models/User') | ||
|
||
Staticman.prototype.getSiteConfig = function () { | ||
return Promise.resolve(helpers.getConfig()) | ||
|
@@ -22,7 +23,8 @@ describe('Auth controller', () => { | |
const mockCode = '1q2w3e4r' | ||
const mockUser = { | ||
login: 'johndoe', | ||
name: 'John Doe' | ||
name: 'John Doe', | ||
email: '[email protected]' | ||
} | ||
|
||
const siteConfig = helpers.getConfig() | ||
|
@@ -55,7 +57,8 @@ describe('Auth controller', () => { | |
return auth(reqWithQuery, res).then(result => { | ||
expect(res.send).toHaveBeenCalledTimes(1) | ||
expect(helpers.decrypt(res.send.mock.calls[0][0].accessToken)).toBe(mockAccessToken) | ||
expect(res.send.mock.calls[0][0].user.username).toBe(mockUser.login) | ||
expect(res.send.mock.calls[0][0].user) | ||
.toEqual(new User('github', mockUser.login, mockUser.email, mockUser.name)) | ||
}) | ||
}) | ||
|
||
|
@@ -100,7 +103,7 @@ describe('Auth controller', () => { | |
return auth(reqWithQuery, res).then(result => { | ||
expect(res.send).toHaveBeenCalledTimes(1) | ||
expect(helpers.decrypt(res.send.mock.calls[0][0].accessToken)).toBe(mockAccessToken) | ||
expect(res.send.mock.calls[0][0].user.login).toBe(mockUser.login) | ||
expect(res.send.mock.calls[0][0].user).toEqual(mockUser) | ||
}) | ||
}) | ||
|
||
|
@@ -182,7 +185,8 @@ describe('Auth controller', () => { | |
const mockCode = '1q2w3e4r' | ||
const mockUser = { | ||
username: 'johndoe', | ||
name: 'John Doe' | ||
name: 'John Doe', | ||
email: '[email protected]' | ||
} | ||
|
||
const siteConfig = helpers.getConfig() | ||
|
@@ -220,7 +224,8 @@ describe('Auth controller', () => { | |
return auth(reqWithQuery, res).then(result => { | ||
expect(res.send).toHaveBeenCalledTimes(1) | ||
expect(helpers.decrypt(res.send.mock.calls[0][0].accessToken)).toBe(mockAccessToken) | ||
expect(res.send.mock.calls[0][0].user.login).toBe(mockUser.login) | ||
expect(res.send.mock.calls[0][0].user) | ||
.toEqual(new User('gitlab', mockUser.username, mockUser.email, mockUser.name)) | ||
}) | ||
}) | ||
|
||
|
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 |
---|---|---|
|
@@ -523,6 +523,7 @@ describe('GitHub interface', () => { | |
test('returns the current authenticated user', () => { | ||
const mockUser = { | ||
login: 'johndoe', | ||
email: '[email protected]', | ||
name: 'John Doe' | ||
} | ||
|
||
|
@@ -539,7 +540,7 @@ describe('GitHub interface', () => { | |
const githubInstance = new GitHub(req.params) | ||
|
||
return githubInstance.getCurrentUser().then((user) => { | ||
expect(user).toEqual(new User('github', 'johndoe', 'John Doe')) | ||
expect(user).toEqual(new User('github', 'johndoe', '[email protected]', 'John Doe')) | ||
}) | ||
}) | ||
|
||
|
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 |
---|---|---|
|
@@ -517,6 +517,7 @@ describe('GitLab interface', () => { | |
test('returns the current authenticated user', () => { | ||
const mockUser = { | ||
username: 'johndoe', | ||
email: '[email protected]', | ||
name: 'John Doe' | ||
} | ||
|
||
|
@@ -536,7 +537,7 @@ describe('GitLab interface', () => { | |
const gitlab = new GitLab(req.params) | ||
|
||
return gitlab.getCurrentUser().then((user) => { | ||
expect(user).toEqual(new User('gitlab', 'johndoe', 'John Doe')) | ||
expect(user).toEqual(new User('gitlab', 'johndoe', '[email protected]', 'John Doe')) | ||
}) | ||
}) | ||
|
||
|
Oops, something went wrong.