Skip to content

Commit

Permalink
fix some test names and add tests for useGithubBot achievement (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
thatkookooguy committed Feb 5, 2017
1 parent db24553 commit 7842030
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/achievibitDB.js
Expand Up @@ -9,7 +9,7 @@ nconf.overrides({
var achievibitDB = require('../achievibitDB');

describe('achievibit DB', function() {
it('sets indexes for the database', function() {
it('should set indexes for the database', function() {

});
});
2 changes: 1 addition & 1 deletion test/eventManager.js
Expand Up @@ -9,7 +9,7 @@ nconf.overrides({
var eventManager = require('../eventManager');

describe('achievibit GitHub Event Manager', function() {
it('it adds repo to DB on ping event', function() {
it('should add repo to DB on ping event', function() {

});
});
66 changes: 66 additions & 0 deletions test/useGithubBot.achievement.js
@@ -0,0 +1,66 @@
var useGithubBot = require('../achievements/useGithubBot.achievement');
var expect = require('chai').expect;

describe('useGithubBot achievement', function() {
it('should be granted if committer is username is web-flow', function() {
var testShall = new Shall();
var pullRequest = new PullRequest();
useGithubBot.check(pullRequest, testShall);
expect(testShall.grantedToUsername).to.be.a('string');
expect(testShall.grantedToUsername).to.equal('creator');
expect(testShall.grantedAchievement).to.be.an('object');
});

it('should not grant if committer is not web-flow', function() {
var testShall = new Shall();
var pullRequest = new PullRequest();

pullRequest.commits[0].committer.username = 'not-web-flow';

useGithubBot.check(pullRequest, testShall);
expect(testShall.grantedToUsername).to.not.exist;
expect(testShall.grantedAchievement).to.not.exist;
});

it('should grant to the pull request author (???)', function() {
var testShall = new Shall();
var pullRequest = new PullRequest();
useGithubBot.check(pullRequest, testShall);
expect(testShall.grantedToUsername).to.be.a('string');
expect(testShall.grantedToUsername).to.equal('creator');
expect(testShall.grantedAchievement).to.be.an('object');
});
});

function Shall() {
var self = this;

self.grantedAchievement = undefined;
self.grantedToUsername = undefined;

self.grant = function(username, achievementObject) {
self.grantedToUsername = username;
self.grantedAchievement = achievementObject;
};
}

function PullRequest() {
return {
'id': 'test',
'url': 'url',
'number': 3,
'creator': {
'username': 'creator'
},
'commits': [
{
'author': {
'username': 'commit-author'
},
'committer': {
'username': 'web-flow'
}
}
]
};
}
6 changes: 3 additions & 3 deletions test/utilities.js
Expand Up @@ -9,13 +9,13 @@ var githubUser = {

describe('achievibit Utilities', function() {
describe('parseUser GitHub User to achievibit User', function() {
it('gets the correct data', function() {
it('should get the correct data', function() {
var achievibitUser = utilities.parseUser(githubUser, false);
expect(achievibitUser).to.be.an('object');
expect(achievibitUser).to.include.keys('username', 'url', 'avatar');
});

it('flags as organization if set to true', function() {
it('should flag as organization if set to true', function() {
var achievibitUser = utilities.parseUser(githubUser, true);
expect(achievibitUser).to.be.an('object');
expect(achievibitUser)
Expand All @@ -24,7 +24,7 @@ describe('achievibit Utilities', function() {
});

describe('getPullRequestIdFromEventData', function() {
it('creates an id string out of GitHub\'s eventData', function() {
it('should create an id string out of GitHub\'s eventData', function() {
var eventData = {
number: 1,
repository: {
Expand Down

0 comments on commit 7842030

Please sign in to comment.