mirror of
https://github.com/hanzoai/passport-github.git
synced 2026-09-23 23:48:07 +00:00
feat(node_id): parses profile node_id, which is documented as the best practice ID to persist as of API V4: https://developer.github.com/v4/guides/using-global-node-ids/#using-global-node-ids-in-migrations
This commit is contained in:
@@ -12,6 +12,7 @@ exports.parse = function(json) {
|
||||
|
||||
var profile = {};
|
||||
profile.id = String(json.id);
|
||||
profile.nodeId = json.node_id;
|
||||
profile.displayName = json.name;
|
||||
profile.username = json.login;
|
||||
profile.profileUrl = json.html_url;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"login": "octocat",
|
||||
"id": 583231,
|
||||
"node_id": "MDQ6VXNlcjU4MzIzMQ==",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/583231?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/octocat",
|
||||
"html_url": "https://github.com/octocat",
|
||||
"followers_url": "https://api.github.com/users/octocat/followers",
|
||||
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/octocat/orgs",
|
||||
"repos_url": "https://api.github.com/users/octocat/repos",
|
||||
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/octocat/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false,
|
||||
"name": "The Octocat",
|
||||
"company": "GitHub",
|
||||
"blog": "http://www.github.com/blog",
|
||||
"location": "San Francisco",
|
||||
"email": null,
|
||||
"hireable": null,
|
||||
"bio": null,
|
||||
"public_repos": 8,
|
||||
"public_gists": 8,
|
||||
"followers": 2914,
|
||||
"following": 9,
|
||||
"created_at": "2011-01-25T18:44:36Z",
|
||||
"updated_at": "2020-01-02T15:35:57Z"
|
||||
}
|
||||
@@ -47,5 +47,26 @@ describe('profile.parse', function() {
|
||||
expect(profile.emails).to.be.undefined;
|
||||
});
|
||||
});
|
||||
|
||||
describe('example profile with `node_id`', function() {
|
||||
var profile;
|
||||
|
||||
before(function(done) {
|
||||
fs.readFile('test/data/octocat-20190115.json', 'utf8', function(err, data) {
|
||||
if (err) { return done(err); }
|
||||
profile = parse(data);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should parse profile', function() {
|
||||
expect(profile.id).to.equal('583231');
|
||||
expect(profile.nodeId).to.equal('MDQ6VXNlcjU4MzIzMQ==');
|
||||
expect(profile.username).to.equal('octocat');
|
||||
expect(profile.displayName).to.equal('The Octocat');
|
||||
expect(profile.profileUrl).to.equal('https://github.com/octocat');
|
||||
expect(profile.emails).to.be.undefined;
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user