Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement support for additional labels (#11)
- Loading branch information
Showing
9 changed files
with
990 additions
and
17 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,19 +1,44 @@ | ||
const { describe, it, afterEach } = require('mocha') | ||
const { beforeEach, describe, it, afterEach } = require('mocha') | ||
const api = require('../index.js') | ||
// import * as assert from 'assert' | ||
// import * as core from '@actions/core' | ||
const core = require('@actions/core') | ||
const fs = require('fs') | ||
const sinon = require('sinon') | ||
const yaml = require('js-yaml') | ||
|
||
const sandbox = sinon.createSandbox() | ||
process.env.GITHUB_EVENT_PATH = process.env.GITHUB_EVENT_PATH || '' | ||
|
||
const metadata = yaml.load(fs.readFileSync('./action.yml', 'utf8')) | ||
|
||
describe('conventional-release-labels', () => { | ||
beforeEach(() => { | ||
sandbox.replace(core, 'getInput', (key) => { | ||
return metadata.inputs[key].default | ||
}) | ||
}) | ||
afterEach(() => { | ||
sandbox.restore() | ||
}) | ||
it('handles unconventional commit', async () => { | ||
const addLabels = sandbox.stub(api, 'addLabels').resolves(undefined) | ||
sandbox.stub(process.env, 'GITHUB_EVENT_PATH').value('./test/fixtures/unconventional.json') | ||
await api.main() | ||
sandbox.assert.notCalled(addLabels) | ||
}) | ||
it('it adds feature label', async () => { | ||
sandbox.stub(api, 'addLabel').resolves(undefined) | ||
sandbox.stub(process.env, 'GITHUB_EVENT_PATH').value('./test/fixtures/feature-pr.json') | ||
const addLabels = sandbox.stub(api, 'addLabels').resolves(undefined) | ||
const removeLabels = sandbox.stub(api, 'removeLabels').resolves(undefined) | ||
sandbox.stub(process.env, 'GITHUB_EVENT_PATH').value('./test/fixtures/feature.json') | ||
await api.main() | ||
sandbox.assert.calledWith(removeLabels, ['feature', 'fix', 'breaking'], sandbox.match.any) | ||
sandbox.assert.calledWith(addLabels, ['feature'], sandbox.match.any) | ||
}) | ||
it('it adds breaking label along with type', async () => { | ||
const addLabels = sandbox.stub(api, 'addLabels').resolves(undefined) | ||
const removeLabels = sandbox.stub(api, 'removeLabels').resolves(undefined) | ||
sandbox.stub(process.env, 'GITHUB_EVENT_PATH').value('./test/fixtures/breaking-fix.json') | ||
await api.main() | ||
sandbox.assert.calledWith(removeLabels, ['feature', 'fix', 'breaking'], sandbox.match.any) | ||
sandbox.assert.calledWith(addLabels, ['breaking', 'fix'], sandbox.match.any) | ||
}) | ||
}) |
Oops, something went wrong.