mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-17 14:29:48 +02:00
Merge pull request #3438 from aloisklink/fix/3362_support-branch-names-that-start-with-branch
fix(git): support unusual prefixes in branch name
This commit is contained in:
@@ -363,6 +363,34 @@ describe('when parsing a gitGraph', function () {
|
||||
expect(Object.keys(parser.yy.getBranches()).length).toBe(2);
|
||||
});
|
||||
|
||||
it('should allow branch names starting with unusual prefixes', function () {
|
||||
const str = `gitGraph:
|
||||
commit
|
||||
%% branch names starting with numbers are not recommended, but are supported by git
|
||||
branch branch01
|
||||
branch checkout02
|
||||
branch cherry-pick03
|
||||
branch branch/example-branch
|
||||
branch merge/test_merge
|
||||
`;
|
||||
|
||||
parser.parse(str);
|
||||
const commits = parser.yy.getCommits();
|
||||
expect(Object.keys(commits).length).toBe(1);
|
||||
expect(parser.yy.getCurrentBranch()).toBe('merge/test_merge');
|
||||
expect(parser.yy.getDirection()).toBe('LR');
|
||||
expect(Object.keys(parser.yy.getBranches()).length).toBe(6);
|
||||
expect(Object.keys(parser.yy.getBranches())).toEqual(
|
||||
expect.arrayContaining([
|
||||
'branch01',
|
||||
'checkout02',
|
||||
'cherry-pick03',
|
||||
'branch/example-branch',
|
||||
'merge/test_merge',
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle new branch checkout', function () {
|
||||
const str = `gitGraph:
|
||||
commit
|
||||
|
Reference in New Issue
Block a user