mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-16 13:59:54 +02:00
#3238 Added test cases
This commit is contained in:
@@ -496,7 +496,7 @@ describe('when parsing a gitGraph', function () {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle merge ids', function () {
|
it('should handle merge with custom ids, tags and typr', function () {
|
||||||
const str = `gitGraph:
|
const str = `gitGraph:
|
||||||
commit
|
commit
|
||||||
branch testBranch
|
branch testBranch
|
||||||
@@ -510,7 +510,7 @@ describe('when parsing a gitGraph', function () {
|
|||||||
commit
|
commit
|
||||||
checkout main
|
checkout main
|
||||||
%% Merge ID and Tag (reverse order)
|
%% Merge ID and Tag (reverse order)
|
||||||
merge testBranch2 id: "4-444" tag: "merge-tag2"
|
merge testBranch2 id: "4-444" tag: "merge-tag2" type:HIGHLIGHT
|
||||||
branch testBranch3
|
branch testBranch3
|
||||||
checkout testBranch3
|
checkout testBranch3
|
||||||
commit
|
commit
|
||||||
@@ -553,6 +553,8 @@ describe('when parsing a gitGraph', function () {
|
|||||||
expect(testBranch2Merge.parents).toStrictEqual([testBranchMerge.id, testBranch2Commit.id]);
|
expect(testBranch2Merge.parents).toStrictEqual([testBranchMerge.id, testBranch2Commit.id]);
|
||||||
expect(testBranch2Merge.tag).toBe('merge-tag2');
|
expect(testBranch2Merge.tag).toBe('merge-tag2');
|
||||||
expect(testBranch2Merge.id).toBe('4-444');
|
expect(testBranch2Merge.id).toBe('4-444');
|
||||||
|
expect(testBranch2Merge.customType).toBe(2);
|
||||||
|
expect(testBranch2Merge.customId).toBe(true);
|
||||||
|
|
||||||
expect(testBranch3Merge.branch).toBe('main');
|
expect(testBranch3Merge.branch).toBe('main');
|
||||||
expect(testBranch3Merge.parents).toStrictEqual([testBranch2Merge.id, testBranch3Commit.id]);
|
expect(testBranch3Merge.parents).toStrictEqual([testBranch2Merge.id, testBranch3Commit.id]);
|
||||||
@@ -687,6 +689,27 @@ describe('when parsing a gitGraph', function () {
|
|||||||
expect(e.message).toBe('Incorrect usage of "merge". Cannot merge a branch to itself');
|
expect(e.message).toBe('Incorrect usage of "merge". Cannot merge a branch to itself');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should throw error when using existing id as merge ID', function () {
|
||||||
|
const str = `gitGraph
|
||||||
|
commit id: "1-111"
|
||||||
|
branch testBranch
|
||||||
|
commit id: "2-222"
|
||||||
|
commit id: "3-333"
|
||||||
|
checkout main
|
||||||
|
merge testBranch id: "1-111"
|
||||||
|
`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
parser.parse(str);
|
||||||
|
// Fail test if above expression doesn't throw anything.
|
||||||
|
expect(true).toBe(false);
|
||||||
|
} catch (e) {
|
||||||
|
expect(e.message).toBe(
|
||||||
|
'Incorrect usage of "merge". Commit with id:1-111 already exists, use different custom Id'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
it('should throw error when trying to merge branches having same heads', function () {
|
it('should throw error when trying to merge branches having same heads', function () {
|
||||||
const str = `gitGraph
|
const str = `gitGraph
|
||||||
commit
|
commit
|
||||||
|
Reference in New Issue
Block a user