Updated test cases for class diagram v2

This commit is contained in:
Ashish Jain 2021-08-20 17:12:46 +02:00
parent 2434a94aae
commit 69a9829041
1 changed files with 12 additions and 7 deletions

View File

@ -275,7 +275,7 @@ describe('Class diagram', () => {
imgSnapshotTest( imgSnapshotTest(
` `
classDiagram classDiagram
class Class10:::exClass { class Class10:::exClass2 {
int[] id int[] id
List~int~ ids List~int~ ids
test(List~int~ ids) List~bool~ test(List~int~ ids) List~bool~
@ -294,7 +294,8 @@ describe('Class diagram', () => {
class Class10 class Class10
class Class20 class Class20
cssClass "Class10, class20" exClass cssClass "Class10, Class20" exClass2
class Class20:::exClass2
`, `,
{} {}
); );
@ -371,12 +372,14 @@ describe('Class diagram', () => {
cy.get('svg') cy.get('svg')
.should((svg) => { .should((svg) => {
expect(svg).to.have.attr('width', '100%'); expect(svg).to.have.attr('width', '100%');
expect(svg).to.have.attr('height', '218'); const height = parseFloat(svg.attr('height'));
expect(height).to.be.within(332, 333);
// expect(svg).to.have.attr('height', '218');
const style = svg.attr('style'); const style = svg.attr('style');
expect(style).to.match(/^max-width: [\d.]+px;$/); expect(style).to.match(/^max-width: [\d.]+px;$/);
const maxWidthValue = parseInt(style.match(/[\d.]+/g).join('')); const maxWidthValue = parseInt(style.match(/[\d.]+/g).join(''));
// use within because the absolute value can be slightly different depending on the environment ±5% // use within because the absolute value can be slightly different depending on the environment ±5%
expect(maxWidthValue).to.be.within(160 * .95, 160 * 1.05); expect(maxWidthValue).to.be.within(203, 204);
}); });
}); });
@ -398,9 +401,11 @@ describe('Class diagram', () => {
.should((svg) => { .should((svg) => {
const width = parseFloat(svg.attr('width')); const width = parseFloat(svg.attr('width'));
// use within because the absolute value can be slightly different depending on the environment ±5% // use within because the absolute value can be slightly different depending on the environment ±5%
expect(width).to.be.within(160 * .95, 160 * 1.05); expect(width).to.be.within(100, 101);
expect(svg).to.have.attr('height', '218'); const height = parseFloat(svg.attr('height'));
expect(svg).to.not.have.attr('style'); expect(height).to.be.within(332, 333);
// expect(svg).to.have.attr('height', '332');
// expect(svg).to.not.have.attr('style');
}); });
}); });
}); });