Skip to content

Commit

Permalink
Renovate/conventional changelog angular 7.x (#3725)
Browse files Browse the repository at this point in the history
* chore: update dependency conventional-changelog-angular to v7

* fix: update conventional-changelog-angular unit tests

* fix: improve scope-enum unit tests

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
silversonicaxel and renovate[bot] committed Nov 18, 2023
1 parent 17ce0e1 commit 128f5f6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
3 changes: 2 additions & 1 deletion @commitlint/parse/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export async function parse(
parser: Parser = sync,
parserOpts?: ParserOptions
): Promise<Commit> {
const defaultOpts = (await defaultChangelogOpts).parserOpts;
const preset = await defaultChangelogOpts();
const defaultOpts = preset.parserOpts;
const opts = {
...defaultOpts,
fieldPattern: null,
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/rules/src/references-empty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const messages = {
};

const opts = (async () => {
const o = await preset;
const o = await preset();
o.parserOpts.commentChar = '#';
return o;
})();
Expand Down
28 changes: 22 additions & 6 deletions @commitlint/rules/src/scope-enum.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ test('scope-enum with plain message and always should succeed empty enum', async
});

test('scope-enum with plain message and never should error empty enum', async () => {
const [actual] = scopeEnum(await parsed.plain, 'never', []);
const [actual, message] = scopeEnum(await parsed.plain, 'never', []);
const expected = false;
expect(actual).toEqual(expected);
expect(message).toEqual('scope must not be one of []');
});

test('with plain message should succeed correct enum', async () => {
Expand All @@ -36,15 +37,17 @@ test('with plain message should succeed correct enum', async () => {
});

test('scope-enum with plain message should error false enum', async () => {
const [actual] = scopeEnum(await parsed.plain, 'always', ['foo']);
const [actual, message] = scopeEnum(await parsed.plain, 'always', ['foo']);
const expected = false;
expect(actual).toEqual(expected);
expect(message).toEqual('scope must be one of [foo]');
});

test('scope-enum with plain message should error forbidden enum', async () => {
const [actual] = scopeEnum(await parsed.plain, 'never', ['bar']);
const [actual, message] = scopeEnum(await parsed.plain, 'never', ['bar']);
const expected = false;
expect(actual).toEqual(expected);
expect(message).toEqual('scope must not be one of [bar]');
});

test('scope-enum with plain message should succeed forbidden enum', async () => {
Expand Down Expand Up @@ -95,14 +98,21 @@ test('scope-enum with empty scope and never should succeed empty enum', async ()
expect(actual).toEqual(expected);
});

test('scope-enum with multiple scopes should succeed on message with multiple scopes', async () => {
const [actual] = scopeEnum(await parsed.multiple, 'never', ['bar', 'baz']);
test('scope-enum with multiple scopes should error on message with multiple scopes', async () => {
const [actual, message] = scopeEnum(await parsed.multiple, 'never', [
'bar',
'baz',
]);
const expected = false;
expect(actual).toEqual(expected);
expect(message).toEqual('scope must not be one of [bar, baz]');
});

test('scope-enum with multiple scopes should error on message with forbidden enum', async () => {
const [actual] = scopeEnum(await parsed.multiple, 'never', ['bar', 'qux']);
const [actual, message] = scopeEnum(await parsed.multiple, 'never', [
'bar',
'qux',
]);
const expected = true;
expect(actual).toEqual(expected);
});
Expand All @@ -113,6 +123,12 @@ test('scope-enum with multiple scopes should error on message with superfluous s
expect(actual).toEqual(expected);
});

test('scope-enum with multiple scope should succeed on message with multiple scopes', async () => {
const [actual] = scopeEnum(await parsed.multiple, 'always', ['bar', 'baz']);
const expected = true;
expect(actual).toEqual(expected);
});

test('scope-enum with multiple scope with comma+space should succeed on message with multiple scopes', async () => {
const [actual] = scopeEnum(await parsed.multipleCommaSpace, 'always', [
'bar',
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/rules/src/subject-exclamation-mark.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {subjectExclamationMark} from './subject-exclamation-mark';
const preset = require('conventional-changelog-angular');

const parseMessage = async (str: string) => {
const {parserOpts} = await preset;
const {parserOpts} = await preset();
return parse(str, undefined, parserOpts);
};

Expand Down

0 comments on commit 128f5f6

Please sign in to comment.