Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix some test names and add tests for useGithubBot achievement (#63)
- Loading branch information
1 parent
db24553
commit 7842030
Showing
4 changed files
with
71 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
} | ||
} | ||
] | ||
}; | ||
} |
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