Skip to content

Commit

Permalink
Added tests for follow and unfollow.
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyGramlich committed May 2, 2019
1 parent bf6b42a commit 2072dc8
Showing 1 changed file with 67 additions and 5 deletions.
72 changes: 67 additions & 5 deletions test/user.spec.js
@@ -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 Down Expand Up @@ -61,14 +63,74 @@ describe('User', function() {
user.listStarredRepos(assertArray(done));
});

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

it('should unfollow user', function(done) {
user.unfollow('ingalls', assertSuccessful(done));
before(function() {
return user.unfollow(userToFollow);
})

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 attempt to follow yourself', 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 attempt to 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();
}));
}));
});
})

describe('unfollowing yourself', function(done) {
const userToUnfollow = testUser.USERNAME;

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

it('should attempt to unfollow yourself', 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

0 comments on commit 2072dc8

Please sign in to comment.