test: requirement, sankey

This commit is contained in:
Yash Singh 2024-04-16 17:14:49 -07:00
parent c993a817d1
commit 6105185d05
7 changed files with 31 additions and 11 deletions

View File

@ -415,10 +415,6 @@ columns 1
).not.toThrow();
}
it('should work with a prototype property', function () {
validateProperty('prototype');
});
it('should work with a __proto__ property', function () {
validateProperty('__proto__');
});

View File

@ -13,10 +13,6 @@ describe('class diagram', function () {
expect(() => parser.parse(`classDiagram\nnamespace ${prop} {\n\tclass A\n}`)).not.toThrow();
}
it('should work with a prototype property', function () {
validateProperty('prototype');
});
it('should work with a __proto__ property', function () {
validateProperty('__proto__');
});

View File

@ -195,7 +195,7 @@ with a second line`
);
});
for (const unsafeProp of ['__proto__', 'constructor', 'prototype']) {
for (const unsafeProp of ['__proto__', 'constructor']) {
it(`should work with node id ${unsafeProp}`, function () {
const flowChart = `graph LR
${unsafeProp} --> A;`;

View File

@ -257,7 +257,7 @@ row2`;
}
);
it.each(['__proto__', 'constructor', 'prototype'])('should allow for a link to %s id', (prop) => {
it.each(['__proto__', 'constructor'])('should allow for a link to %s id', (prop) => {
expect(() =>
parser.parse(`gantt
dateFormat YYYY-MM-DD

View File

@ -1097,7 +1097,7 @@ describe('when parsing a gitGraph', function () {
});
describe('unsafe properties', () => {
for (const prop of ['__proto__', 'constructor', 'prototype']) {
for (const prop of ['__proto__', 'constructor']) {
it(`should work with custom commit id or branch name ${prop}`, () => {
const str = `gitGraph
commit id:"${prop}"

View File

@ -578,4 +578,25 @@ line 2`;
let foundRelationship = requirementDb.getRelationships()[0];
expect(foundRelationship.type).toBe(expectedType);
});
for (const property of ['__proto__', 'constructor']) {
it(`will accept ${property} as requirement id`, function () {
reqDiagram.parser.parse(`requirementDiagram
requirement ${property} {
id: 1
text: the test text.
risk: high
verifymethod: test
}`);
expect(reqDiagram.parser.yy.getRequirements().size).toBe(1);
});
it(`will accept ${property} as element id`, function () {
reqDiagram.parser.parse(`requirementDiagram
element ${property} {
type: simulation
}`);
expect(reqDiagram.parser.yy.getElements().size).toBe(1);
});
}
});

View File

@ -20,5 +20,12 @@ describe('Sankey diagram', function () {
sankey.parser.parse(graphDefinition);
});
it('allows __proto__ as id', function () {
sankey.parser.parse(prepareTextForParsing(`sankey-beta
__proto__,A,0.597
A,__proto__,0.403
`));
});
});
});