mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Fix test / Add Tests
This commit is contained in:
parent
64a935515c
commit
117f0ab6da
@ -224,9 +224,18 @@ export const parseBoxData = function (str) {
|
|||||||
let title = match != null && match[2] ? match[2].trim() : undefined;
|
let title = match != null && match[2] ? match[2].trim() : undefined;
|
||||||
|
|
||||||
// check that the string is a color
|
// check that the string is a color
|
||||||
if (!CSS.supports('color', color)) {
|
if (window && window.CSS) {
|
||||||
color = 'transparent';
|
if (!window.CSS.supports('color', color)) {
|
||||||
title = str.trim();
|
color = 'transparent';
|
||||||
|
title = str.trim();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var s = new Option().style;
|
||||||
|
s.color = color;
|
||||||
|
if (s.color !== color) {
|
||||||
|
color = 'transparent';
|
||||||
|
title = str.trim();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const boxData = {
|
const boxData = {
|
||||||
|
@ -1312,8 +1312,53 @@ link a: Tests @ https://tests.contoso.com/?svc=alice@contoso.com
|
|||||||
expect(boxes[0].actorKeys).toEqual(['a', 'b']);
|
expect(boxes[0].actorKeys).toEqual(['a', 'b']);
|
||||||
expect(boxes[0].fill).toEqual('green');
|
expect(boxes[0].fill).toEqual('green');
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
it('should handle box without color', function () {
|
||||||
|
const str = `
|
||||||
|
sequenceDiagram
|
||||||
|
box Group 1
|
||||||
|
participant a as Alice
|
||||||
|
participant b as Bob
|
||||||
|
end
|
||||||
|
participant c as Charlie
|
||||||
|
links a: { "Repo": "https://repo.contoso.com/", "Dashboard": "https://dashboard.contoso.com/" }
|
||||||
|
links b: { "Dashboard": "https://dashboard.contoso.com/" }
|
||||||
|
links a: { "On-Call": "https://oncall.contoso.com/?svc=alice" }
|
||||||
|
link a: Endpoint @ https://alice.contoso.com
|
||||||
|
link a: Swagger @ https://swagger.contoso.com
|
||||||
|
link a: Tests @ https://tests.contoso.com/?svc=alice@contoso.com
|
||||||
|
`;
|
||||||
|
|
||||||
|
mermaidAPI.parse(str);
|
||||||
|
const boxes = diagram.db.getBoxes();
|
||||||
|
expect(boxes[0].name).toEqual('Group 1');
|
||||||
|
expect(boxes[0].actorKeys).toEqual(['a', 'b']);
|
||||||
|
expect(boxes[0].fill).toEqual('transparent');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should handle box without description', function () {
|
||||||
|
const str = `
|
||||||
|
sequenceDiagram
|
||||||
|
box Aqua
|
||||||
|
participant a as Alice
|
||||||
|
participant b as Bob
|
||||||
|
end
|
||||||
|
participant c as Charlie
|
||||||
|
links a: { "Repo": "https://repo.contoso.com/", "Dashboard": "https://dashboard.contoso.com/" }
|
||||||
|
links b: { "Dashboard": "https://dashboard.contoso.com/" }
|
||||||
|
links a: { "On-Call": "https://oncall.contoso.com/?svc=alice" }
|
||||||
|
link a: Endpoint @ https://alice.contoso.com
|
||||||
|
link a: Swagger @ https://swagger.contoso.com
|
||||||
|
link a: Tests @ https://tests.contoso.com/?svc=alice@contoso.com
|
||||||
|
`;
|
||||||
|
|
||||||
|
mermaidAPI.parse(str);
|
||||||
|
const boxes = diagram.db.getBoxes();
|
||||||
|
expect(boxes[0].name).toBeFalsy();
|
||||||
|
expect(boxes[0].actorKeys).toEqual(['a', 'b']);
|
||||||
|
expect(boxes[0].fill).toEqual('Aqua');
|
||||||
|
});
|
||||||
|
});
|
||||||
describe('when checking the bounds in a sequenceDiagram', function () {
|
describe('when checking the bounds in a sequenceDiagram', function () {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
let conf = {
|
let conf = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user