UNPKG

backport

Version:

A CLI tool that automates the process of backporting commits

74 lines 3.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const getBackportBranchName_1 = require("./getBackportBranchName"); describe('getBackportBranchName', () => { describe('when options.backportBranchName is not set', () => { it('returns the default name with PR number', () => { const commits = [{ sourcePullRequest: { number: 1234 } }]; const name = (0, getBackportBranchName_1.getBackportBranchName)({ options: { backportBranchName: undefined }, targetBranch: '7.x', commits, }); expect(name).toBe('backport/7.x/pr-1234'); }); it('returns the default name with commit sha', () => { const commits = [{ sourceCommit: { sha: 'abcde' } }]; const name = (0, getBackportBranchName_1.getBackportBranchName)({ options: { backportBranchName: undefined }, targetBranch: '7.x', commits, }); expect(name).toBe('backport/7.x/commit-abcde'); }); }); describe('template variables are supported when using options.backportBranchName', () => { it('{{targetBranch}}', () => { const commits = [{ sourcePullRequest: { number: 1234 } }]; const name = (0, getBackportBranchName_1.getBackportBranchName)({ options: { backportBranchName: 'bp/target-{{targetBranch}}', }, targetBranch: '7.x', commits, }); expect(name).toBe('bp/target-7.x'); }); it('{{refValues}}', () => { const commits = [{ sourcePullRequest: { number: 1234 } }]; const name = (0, getBackportBranchName_1.getBackportBranchName)({ options: { backportBranchName: 'bp/ref-{{refValues}}', }, targetBranch: '7.x', commits, }); expect(name).toBe('bp/ref-pr-1234'); }); it('{{sourcePullRequest.number}}', () => { const commits = [{ sourcePullRequest: { number: 1234 } }]; const name = (0, getBackportBranchName_1.getBackportBranchName)({ options: { backportBranchName: 'bp/pr-{{sourcePullRequest.number}}', }, targetBranch: '7.x', commits, }); expect(name).toBe('bp/pr-1234'); }); it('{{sourcePullRequest.title}}', () => { const commits = [ { sourcePullRequest: { title: 'My PR title', number: 1234 } }, ]; const name = (0, getBackportBranchName_1.getBackportBranchName)({ options: { backportBranchName: 'bp/pr-{{sourcePullRequest.title}}', }, targetBranch: '7.x', commits, }); expect(name).toBe('bp/pr-My PR title'); }); }); }); //# sourceMappingURL=getBackportBranchName.test.js.map