Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix follow and unfollow user#554

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall 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
4 changes: 2 additions & 2 deletionslib/User.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -187,7 +187,7 @@ class User extends Requestable {
* @return {Promise} - the promise for the http request
*/
follow(username, cb) {
return this._request('PUT', `/user/following/${this.__user}`, null, cb);
return this._request('PUT', `/user/following/${username}`, null, cb);
}

/**
Expand All@@ -198,7 +198,7 @@ class User extends Requestable {
* @return {Promise} - the promise for the http request
*/
unfollow(username, cb) {
return this._request('DELETE', `/user/following/${this.__user}`, null, cb);
return this._request('DELETE', `/user/following/${username}`, null, cb);
}

/**
Expand Down
55 changes: 50 additions & 5 deletionstest/user.spec.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
import expect from 'must';

import Github from '../lib/GitHub';
import testUser from './fixtures/user.json';
import {assertSuccessful, assertArray} from './helpers/callbacks';
Expand DownExpand Up@@ -76,14 +78,57 @@ describe('User', function() {
user.listStarredGists(option, assertArray(done));
});

it('should follow user', function(done) {
user.follow('ingalls', assertSuccessful(done));
});
describe('following a user', function() {
const userToFollow = 'ingalls';

before(function() {
return user.unfollow(userToFollow);
})

it('should unfollow user', function(done) {
user.unfollow('ingalls', assertSuccessful(done));
it('should follow user', function(done) {
user.follow(userToFollow, assertSuccessful(done, function(err, resp) {
user._request('GET', `/user/following`, null, assertSuccessful(done, function(err, following) {
expect((following.some(user => user['login'] === userToFollow))).to.be.true();
done();
}));
}));
});
});

describe('following yourself', function() {
const userToFollow = testUser.USERNAME;

before(function() {
return user.unfollow(userToFollow);
})

it('should not list yourself as one of your followers', function(done) {
user.follow(userToFollow, assertSuccessful(done, function(err, resp) {
user._request('GET', `/user/following`, null, assertSuccessful(done, function(err, following) {
expect((following.some(user => user['login'] === userToFollow))).to.be.false();
done();
}));
}));
});
})

describe('unfollowing a user', function(done) {
const userToUnfollow = 'ingalls';

before(function() {
return user.follow(userToUnfollow);
})

it('should unfollow a user', function(done) {
user.unfollow(userToUnfollow, assertSuccessful(done, function(err, resp) {
user._request('GET', `/user/following`, null, assertSuccessful(done, function(err, following) {
expect((following.some(user => user['login'] === userToUnfollow))).to.be.false();
done();
}));
}));
});
})

it('should list the email addresses of the user', function(done) {
user.getEmails(assertSuccessful(done));
});
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp