Skip to content

Commit

Permalink
test: new test case for parsing multiple commits
Browse files Browse the repository at this point in the history
- added new test cases for parsing multiple commits from a single message
- added fixture file for multiple commits in a single message
- changed the order of the expected commits in `multiple-messages` and `1257-breaking-change` fixtures since the order of the commits in the is not reversed anymore
  • Loading branch information
dgokcin authored and Deniz Gökçin committed Aug 15, 2024
1 parent 7bba54b commit 736a363
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
36 changes: 30 additions & 6 deletions test/commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ describe('parseConventionalCommits', () => {
const commits = [buildCommitFromFixture('multiple-messages')];
const conventionalCommits = parseConventionalCommits(commits);
expect(conventionalCommits).lengthOf(2);
expect(conventionalCommits[0].type).to.equal('fix');
expect(conventionalCommits[0].type).to.equal('feat');
expect(conventionalCommits[0].scope).is.null;
expect(conventionalCommits[1].type).to.equal('feat');
expect(conventionalCommits[1].type).to.equal('fix');
expect(conventionalCommits[1].scope).is.null;
});

Expand Down Expand Up @@ -154,6 +154,30 @@ describe('parseConventionalCommits', () => {
expect(conventionalCommits[0].message).not.include('I should be removed');
});

it('parses multiple commits from a single message', async () => {
const commits = [buildCommitFromFixture('multiple-commits-single-message')];
const conventionalCommits = parseConventionalCommits(commits);
expect(conventionalCommits).lengthOf(3);
expect(conventionalCommits[0].type).to.equal('feat');
expect(conventionalCommits[0].scope).is.null;
expect(conventionalCommits[1].type).to.equal('fix');
expect(conventionalCommits[1].scope).to.equal('utils');
expect(conventionalCommits[2].type).to.equal('feat');
expect(conventionalCommits[2].scope).to.equal('utils');
});

it('parses multiple commits from a single message', async () => {
const commits = [buildCommitFromFixture('multiple-commits-single-message')];
const conventionalCommits = parseConventionalCommits(commits);
expect(conventionalCommits).lengthOf(3);
expect(conventionalCommits[0].type).to.equal('feat');
expect(conventionalCommits[0].scope).is.null;
expect(conventionalCommits[1].type).to.equal('fix');
expect(conventionalCommits[1].scope).to.equal('utils');
expect(conventionalCommits[2].type).to.equal('feat');
expect(conventionalCommits[2].scope).to.equal('utils');
});

// Refs: #1257
it('removes content before and after BREAKING CHANGE in body', async () => {
const commits = [buildCommitFromFixture('1257-breaking-change')];
Expand Down Expand Up @@ -211,10 +235,10 @@ describe('parseConventionalCommits', () => {

const conventionalCommits = parseConventionalCommits([commit]);
expect(conventionalCommits).lengthOf(2);
expect(conventionalCommits[0].type).to.eql('feat');
expect(conventionalCommits[0].bareMessage).to.eql('another feature');
expect(conventionalCommits[1].type).to.eql('fix');
expect(conventionalCommits[1].bareMessage).to.eql('some fix');
expect(conventionalCommits[0].type).to.eql('fix');
expect(conventionalCommits[0].bareMessage).to.eql('some fix');
expect(conventionalCommits[1].type).to.eql('feat');
expect(conventionalCommits[1].bareMessage).to.eql('another feature');
});

it('handles a special commit separator', async () => {
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/commit-messages/multiple-commits-single-message.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
feat: adds v4 UUID to crypto

This adds support for v4 UUIDs to the library.

fix(utils): unicode no longer throws exception

- some more stuff

feat(utils): update encode to support unicode

- does stuff
- more stuff

0 comments on commit 736a363

Please sign in to comment.