Skip to content

Commit

Permalink
test: improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad Nassri committed Oct 30, 2020
1 parent 334c00b commit f9b1aef
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions action/lib/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module.exports = async function (config = 'conventional', commits) {
let fail = false
const report = []

core.info(`config: ${config}`)

for (let { sha, id, commit, message } of commits) {
message = message || commit.message
sha = sha || id
Expand Down
2 changes: 1 addition & 1 deletion action/test/commits-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test('commits -> errors', async assert => {
assert.equal(process.exit.getCall(0).args[0], 1)

assert.ok(core.info.called)
assert.equal(core.info.getCall(0).args[0], '2f8c821: Update README.md')
assert.equal(core.info.getCall(1).args[0], '2f8c821: Update README.md')

assert.ok(core.error.called)
assert.equal(core.error.getCall(0).args[0], '✖ subject may not be empty')
Expand Down
4 changes: 2 additions & 2 deletions action/test/commits-valid.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ test('commits -> valid', async assert => {
assert.same(process.exitCode, null)

assert.ok(core.info.called)
assert.equal(core.info.getCall(0).args[0], '2f8c821: feat(readme): update readme.md')
assert.equal(core.info.getCall(1).args[0], 'bf4c344: feat(food)!: add ice cream')
assert.equal(core.info.getCall(1).args[0], '2f8c821: feat(readme): update readme.md')
assert.equal(core.info.getCall(2).args[0], 'bf4c344: feat(food)!: add ice cream')
assert.notOk(core.error.called)
assert.notOk(core.warning.called)

Expand Down
2 changes: 1 addition & 1 deletion action/test/commits-warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test('commits -> warnings', async assert => {
assert.same(process.exitCode, null)

assert.ok(core.info.called)
assert.equal(core.info.getCall(0).args[0], '2f8c821: fix: some message\nbody')
assert.equal(core.info.getCall(1).args[0], '2f8c821: fix: some message\nbody')
assert.notOk(core.error.called)
assert.ok(core.warning.called)
assert.equal(core.warning.getCall(0).args[0], '⚠ body must have leading blank line')
Expand Down
7 changes: 5 additions & 2 deletions action/test/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const core = require('@actions/core')
const lint = require('../lib/lint')

test('commits -> success', async assert => {
assert.plan(1)
assert.plan(2)

sinon.stub(core, 'info')
sinon.stub(core, 'error')
Expand All @@ -20,6 +20,7 @@ test('commits -> success', async assert => {
}
}])

assert.equal(core.info.getCall(0).args[0], 'config: angular-type-enum')
assert.notOk(core.error.called)

core.info.restore()
Expand Down Expand Up @@ -60,7 +61,7 @@ test('commits -> fail', async assert => {
})

test('config -> custom', async assert => {
assert.plan(6)
assert.plan(7)

sinon.stub(core, 'info')
sinon.stub(core, 'error')
Expand All @@ -77,6 +78,8 @@ test('config -> custom', async assert => {
}
}])

assert.equal(core.info.getCall(0).args[0], 'config: fixture.yml')

assert.ok(process.exit.called)
assert.equal(process.exit.getCall(0).args[0], 1)

Expand Down
4 changes: 2 additions & 2 deletions action/test/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test('event -> PR', async assert => {
assert.same(process.exitCode, null)

assert.ok(core.info.called)
assert.equal(core.info.getCall(0).args[0], '2f8c821: feat(readme): update readme.md')
assert.equal(core.info.getCall(1).args[0], '2f8c821: feat(readme): update readme.md')
assert.notOk(core.error.called)
assert.notOk(core.warning.called)

Expand All @@ -50,7 +50,7 @@ test('event -> push', async assert => {
assert.same(process.exitCode, null)

assert.ok(core.info.called)
assert.equal(core.info.getCall(0).args[0], '2f8c821: feat(readme): update readme.md')
assert.equal(core.info.getCall(1).args[0], '2f8c821: feat(readme): update readme.md')
assert.notOk(core.error.called)
assert.notOk(core.warning.called)

Expand Down

0 comments on commit f9b1aef

Please sign in to comment.