cz-jira-smart-commit
Advanced tools
Comparing version 2.0.1 to 3.0.0
27
index.js
@@ -6,3 +6,6 @@ var inquirer = require('inquirer') | ||
// fine. | ||
module.exports = {prompter: prompter}; | ||
module.exports = { | ||
prompter: prompter, | ||
formatCommit: formatCommit | ||
}; | ||
@@ -76,13 +79,15 @@ // When a user runs `git cz`, prompter will | ||
}, | ||
], commitAnswers); | ||
]).then((answers) => { | ||
formatCommit(commit, answers); | ||
}); | ||
} | ||
function commitAnswers(answers) { | ||
commit(filter([ | ||
answers.message, | ||
answers.issues, | ||
answers.workflow ? '#' + answers.workflow : undefined, | ||
answers.time ? '#time ' + answers.time : undefined, | ||
answers.comment ? '#comment ' + answers.comment : undefined, | ||
]).join(' ')); | ||
} | ||
function formatCommit(commit, answers) { | ||
commit(filter([ | ||
answers.message, | ||
answers.issues, | ||
answers.workflow ? '#' + answers.workflow : undefined, | ||
answers.time ? '#time ' + answers.time : undefined, | ||
answers.comment ? '#comment ' + answers.comment : undefined, | ||
]).join(' ')); | ||
} | ||
@@ -89,0 +94,0 @@ |
@@ -1,62 +0,46 @@ | ||
import sinon from 'sinon'; | ||
import chai from 'chai'; | ||
import sinonChai from 'sinon-chai'; | ||
import proxyquire from 'proxyquire'; | ||
const {expect} = chai; | ||
const sinon = require('sinon'); | ||
const chai = require('chai'); | ||
const sinonChai = require('sinon-chai'); | ||
const expect = chai.expect; | ||
chai.use(sinonChai); | ||
describe(`prompter`, () => { | ||
let inquirer, commit, prompter, commitAnswers; | ||
const czJiraSmartCommit = require('./index.js'); | ||
before(() => { | ||
commit = sinon.spy(); | ||
inquirer = {prompt: sinon.spy()}; | ||
prompter = proxyquire('./', {inquirer}).prompter; | ||
describe('prompt for inputs', () => { | ||
it('should be a function', () => { | ||
expect(czJiraSmartCommit.prompter).to.be.a('function'); | ||
}); | ||
}); | ||
beforeEach(() => { | ||
prompter(null, commit); | ||
commitAnswers = inquirer.prompt.getCall(0).args[1]; | ||
}); | ||
describe('format commits', () => { | ||
it(`should call commit with the proper message`, () => { | ||
const message = 'sample commit message'; | ||
const issues = 'CZ-234 CZ-235'; | ||
const workflow = 'closed'; | ||
const time = '3y 2w 7d 8h 30m'; | ||
const comment = 'This took waaaaay too long'; | ||
commitAnswers({message, issues, workflow, time, comment}); | ||
expect(commit).to.have.been.calledWith([ | ||
message, | ||
issues, | ||
`#${workflow}`, | ||
`#time ${time}`, | ||
`#comment ${comment}` | ||
].join(' ')); | ||
}); | ||
const message = 'sample commit message'; | ||
const issues = 'CZ-234 CZ-235'; | ||
const workflow = 'closed'; | ||
const time = '3y 2w 7d 8h 30m'; | ||
const comment = 'This took waaaaay too long'; | ||
['workflow', 'time', 'comment'].forEach((item) => { | ||
it(`should just leave off ${item} if it's not specified`, () => { | ||
const message = 'sample commit message'; | ||
const issues = 'CZ-234 CZ-235'; | ||
const workflow = 'closed'; | ||
const time = '3y 2w 7d 8h 30m'; | ||
const comment = 'This took waaaaay too long'; | ||
const answers = {message, issues, workflow, time, comment}; | ||
delete answers[item]; | ||
commitAnswers(answers); | ||
expect(commit).to.have.been.calledWith(filter([ | ||
message, | ||
issues, | ||
item !== 'workflow' ? `#${workflow}` : undefined, | ||
item !== 'time' ? `#time ${time}` : undefined, | ||
item !== 'comment' ? `#comment ${comment}` : undefined | ||
]).join(' ')); | ||
}); | ||
it('should be a function', () => { | ||
expect(czJiraSmartCommit.formatCommit).to.be.a('function'); | ||
}); | ||
it('should perform a full commit', () => { | ||
czJiraSmartCommit.formatCommit((result) => { | ||
expect(result).to.equal('sample commit message CZ-234 CZ-235 #closed #time 3y 2w 7d 8h 30m #comment This took waaaaay too long') | ||
}, {message, issues, workflow, time, comment}); | ||
}); | ||
it('should commit without a workflow', () => { | ||
czJiraSmartCommit.formatCommit((result) => { | ||
expect(result).to.equal('sample commit message CZ-234 CZ-235 #time 3y 2w 7d 8h 30m #comment This took waaaaay too long') | ||
}, {message, issues, time, comment}); | ||
}); | ||
it('should commit without a time', () => { | ||
czJiraSmartCommit.formatCommit((result) => { | ||
expect(result).to.equal('sample commit message CZ-234 CZ-235 #closed #comment This took waaaaay too long') | ||
}, {message, issues, workflow, comment}); | ||
}); | ||
it('should commit without a comment', () => { | ||
czJiraSmartCommit.formatCommit((result) => { | ||
expect(result).to.equal('sample commit message CZ-234 CZ-235 #closed #time 3y 2w 7d 8h 30m') | ||
}, {message, issues, workflow, time}); | ||
}); | ||
}); | ||
function filter(array) { | ||
return array.filter(Boolean); | ||
} |
{ | ||
"name": "cz-jira-smart-commit", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "A commitizen adapter for Jira smart commits", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,2 +9,12 @@ # cz-jira-smart-commit | ||
### Global Installation | ||
For a quick global installation of the plugin, simply run the `install.sh` script present in this repo: | ||
``` | ||
chmod +x install.sh | ||
./install.sh | ||
``` | ||
### Add this adapter | ||
@@ -11,0 +21,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
86326
9
53
136