test(dev-infra): extract commit message build function into testing util function (#41476)
Creates a testing utility function to build commit message strings. PR Close #41476
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
*/
|
||||
|
||||
import {parseCommitMessage} from './parse';
|
||||
import {commitMessageBuilder, CommitMessageParts} from './test-util';
|
||||
|
||||
|
||||
const commitValues = {
|
||||
const commitValues: CommitMessageParts = {
|
||||
prefix: '',
|
||||
type: 'fix',
|
||||
npmScope: '',
|
||||
@@ -19,12 +19,7 @@ const commitValues = {
|
||||
footer: 'Closes #1',
|
||||
};
|
||||
|
||||
function buildCommitMessage(params: Partial<typeof commitValues> = {}) {
|
||||
const {prefix, npmScope, type, scope, summary, body, footer} = {...commitValues, ...params};
|
||||
const scopeSlug = npmScope ? `${npmScope}/${scope}` : scope;
|
||||
return `${prefix}${type}${scopeSlug ? '(' + scopeSlug + ')' : ''}: ${summary}\n\n${body}\n\n${
|
||||
footer}`;
|
||||
}
|
||||
const buildCommitMessage = commitMessageBuilder(commitValues);
|
||||
|
||||
|
||||
describe('commit message parsing:', () => {
|
||||
|
||||
Reference in New Issue
Block a user