Skip to content

Commit

Permalink
style: prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Nov 21, 2019
1 parent 4c92195 commit b5996a7
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 14 deletions.
8 changes: 7 additions & 1 deletion test/analyze-commit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ test('Match only if all criteria are verified', t => {
};

t.is(
analyzeCommit([{type: 'fix', release: 'minor'}, {type: 'fix', breaking: true, release: 'major'}], commit),
analyzeCommit(
[
{type: 'fix', release: 'minor'},
{type: 'fix', breaking: true, release: 'major'},
],
commit
),
'major'
);
});
Expand Down
67 changes: 56 additions & 11 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ test('Return "major" if there is a breaking change, using default releaseRules',
});

test('Return "major" if there is a "conventionalcommits" breaking change, using default releaseRules', async t => {
const commits = [{hash: '123', message: 'fix: First fix'}, {hash: '456', message: 'feat!: Breaking change feature'}];
const commits = [
{hash: '123', message: 'fix: First fix'},
{hash: '456', message: 'feat!: Breaking change feature'},
];
const releaseType = await analyzeCommits({preset: 'conventionalcommits'}, {cwd, commits, logger: t.context.logger});

t.is(releaseType, 'major');
Expand Down Expand Up @@ -174,7 +177,13 @@ test('Return "patch" if there is only types set to "patch", using default releas
test('Allow to use glob in "releaseRules" configuration', async t => {
const commits = [{message: 'Chore: First chore (fixes #123)'}, {message: 'Docs: update README (fixes #456)'}];
const releaseType = await analyzeCommits(
{preset: 'eslint', releaseRules: [{tag: 'Chore', release: 'patch'}, {message: '*README*', release: 'minor'}]},
{
preset: 'eslint',
releaseRules: [
{tag: 'Chore', release: 'patch'},
{message: '*README*', release: 'minor'},
],
},
{cwd, commits, logger: t.context.logger}
);

Expand All @@ -187,7 +196,10 @@ test('Allow to use glob in "releaseRules" configuration', async t => {
});

test('Return "null" if no rule match', async t => {
const commits = [{hash: '123', message: 'doc: doc update'}, {hash: '456', message: 'chore: Chore'}];
const commits = [
{hash: '123', message: 'doc: doc update'},
{hash: '456', message: 'chore: Chore'},
];
const releaseType = await analyzeCommits({}, {cwd, commits, logger: t.context.logger});

t.is(releaseType, null);
Expand All @@ -204,7 +216,13 @@ test('Process rules in order and apply highest match', async t => {
{hash: '456', message: 'Docs: update README (fixes #456)'},
];
const releaseType = await analyzeCommits(
{preset: 'eslint', releaseRules: [{tag: 'Chore', release: 'minor'}, {tag: 'Chore', release: 'patch'}]},
{
preset: 'eslint',
releaseRules: [
{tag: 'Chore', release: 'minor'},
{tag: 'Chore', release: 'patch'},
],
},
{cwd, commits, logger: t.context.logger}
);

Expand All @@ -222,7 +240,13 @@ test('Process rules in order and apply highest match from config even if default
{hash: '456', message: 'Docs: update README (fixes #456) \n\n BREAKING CHANGE: break something'},
];
const releaseType = await analyzeCommits(
{preset: 'eslint', releaseRules: [{tag: 'Chore', release: 'patch'}, {breaking: true, release: 'minor'}]},
{
preset: 'eslint',
releaseRules: [
{tag: 'Chore', release: 'patch'},
{breaking: true, release: 'minor'},
],
},
{cwd, commits, logger: t.context.logger}
);

Expand All @@ -235,7 +259,10 @@ test('Process rules in order and apply highest match from config even if default
});

test('Allow to overwrite default "releaseRules" with "false"', async t => {
const commits = [{hash: '123', message: 'chore: First chore'}, {hash: '456', message: 'feat: new feature'}];
const commits = [
{hash: '123', message: 'chore: First chore'},
{hash: '456', message: 'feat: new feature'},
];
const releaseType = await analyzeCommits(
{preset: 'angular', releaseRules: [{type: 'feat', release: false}]},
{cwd, commits, logger: t.context.logger}
Expand All @@ -250,9 +277,18 @@ test('Allow to overwrite default "releaseRules" with "false"', async t => {
});

test('Commits with an associated custom release type have higher priority than commits with release "false"', async t => {
const commits = [{hash: '123', message: 'feat: Feature to skip'}, {hash: '456', message: 'docs: update README'}];
const commits = [
{hash: '123', message: 'feat: Feature to skip'},
{hash: '456', message: 'docs: update README'},
];
const releaseType = await analyzeCommits(
{preset: 'angular', releaseRules: [{type: 'feat', release: false}, {type: 'docs', release: 'patch'}]},
{
preset: 'angular',
releaseRules: [
{type: 'feat', release: false},
{type: 'docs', release: 'patch'},
],
},
{cwd, commits, logger: t.context.logger}
);

Expand All @@ -265,7 +301,10 @@ test('Commits with an associated custom release type have higher priority than c
});

test('Commits with an associated default release type have higher priority than commits with release "false"', async t => {
const commits = [{hash: '123', message: 'feat: new feature'}, {hash: '456', message: 'fix: new Fix'}];
const commits = [
{hash: '123', message: 'feat: new feature'},
{hash: '456', message: 'fix: new Fix'},
];
const releaseType = await analyzeCommits(
{preset: 'angular', releaseRules: [{type: 'feat', release: false}]},
{cwd, commits, logger: t.context.logger}
Expand All @@ -280,7 +319,10 @@ test('Commits with an associated default release type have higher priority than
});

test('Use default "releaseRules" if none of provided match', async t => {
const commits = [{hash: '123', message: 'Chore: First chore'}, {hash: '456', message: 'Update: new feature'}];
const commits = [
{hash: '123', message: 'Chore: First chore'},
{hash: '456', message: 'Update: new feature'},
];
const releaseType = await analyzeCommits(
{preset: 'eslint', releaseRules: [{tag: 'Chore', release: 'patch'}]},
{cwd, commits, logger: t.context.logger}
Expand All @@ -295,7 +337,10 @@ test('Use default "releaseRules" if none of provided match', async t => {
});

test('Filter out empty commits', async t => {
const commits = [{hash: '123', message: ''}, {hash: '456', message: 'fix(scope1): First fix'}];
const commits = [
{hash: '123', message: ''},
{hash: '456', message: 'fix(scope1): First fix'},
];
const releaseType = await analyzeCommits({}, {cwd, commits, logger: t.context.logger});

t.is(releaseType, 'patch');
Expand Down
12 changes: 10 additions & 2 deletions test/load-release-rules.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ test('Return undefined if "releaseRules" not set', t => {

test('Preserve release rules set to "false" or "null"', t => {
const releaseRules = loadReleaseRules(
{releaseRules: [{type: 'feat', release: false}, {type: 'fix', release: null}]},
{
releaseRules: [
{type: 'feat', release: false},
{type: 'fix', release: null},
],
},
{cwd}
);

t.deepEqual(releaseRules, [{type: 'feat', release: false}, {type: 'fix', release: null}]);
t.deepEqual(releaseRules, [
{type: 'feat', release: false},
{type: 'fix', release: null},
]);
});

test('Throw error if "releaseRules" reference invalid commit type', t => {
Expand Down

0 comments on commit b5996a7

Please sign in to comment.