Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(getNextReleaseType): add tests for false breaking changes #67

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions src/utils/__test__/getNextReleaseType.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,72 @@ it('returns "major" for commits with a "!" type appendix', async () => {
).toBe('major')
})

it('does not return "major" for a commit that includes "breaking change" generic text', async () => {
expect(
getNextReleaseType(
await parseCommits([
mockCommit({
subject: 'fix: some breaking change',
}),
]),
),
).toBe('patch')

expect(
getNextReleaseType(
await parseCommits([
mockCommit({
subject: 'feat(scope): some breaking change',
}),
]),
),
).toBe('minor')

expect(
getNextReleaseType(
await parseCommits([
mockCommit({
subject: 'feat(scope): abc',
body: 'this is good because it is not a breaking change',
}),
]),
),
).toBe('minor')

expect(
getNextReleaseType(
await parseCommits([
mockCommit({
subject: 'docs: abc',
body: 'should this be a BREAKING CHANGE?',
}),
]),
),
).toBe(null)
})

it('does not return "major" for a commit that includes "!" in its message', async () => {
expect(
getNextReleaseType(
await parseCommits([
mockCommit({
subject: 'fix: adds "!" as supported character',
}),
]),
),
).toBe('patch')

expect(
getNextReleaseType(
await parseCommits([
mockCommit({
subject: 'feat: adds "!" as supported character',
}),
]),
),
).toBe('minor')
})

it('returns "minor" for "feat" commits', async () => {
expect(
getNextReleaseType(
Expand Down
8 changes: 0 additions & 8 deletions src/utils/getNextReleaseType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,5 @@ export function getNextReleaseType(
}
}

/**
* @fixme Commit messages can also append "!" to the scope
* to indicate that the commit is a breaking change.
* @see https://www.conventionalcommits.org/en/v1.0.0/#summary
*
* Unfortunately, "conventional-commits-parser" does not support that.
*/

return ranges[0] || ranges[1]
}