-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4501 from Yokozuna59/standardized-pie-definitions
standardized pie definitions
- Loading branch information
Showing
24 changed files
with
702 additions
and
563 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Mocked pie (picChart) diagram renderer | ||
*/ | ||
import { vi } from 'vitest'; | ||
|
||
const draw = vi.fn().mockImplementation(() => ''); | ||
|
||
export const renderer = { draw }; |
82 changes: 39 additions & 43 deletions
82
cypress/integration/rendering/pie.spec.js → cypress/integration/rendering/pie.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,85 @@ | ||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts'; | ||
|
||
describe('Pie Chart', () => { | ||
describe('pie chart', () => { | ||
it('should render a simple pie diagram', () => { | ||
imgSnapshotTest( | ||
`pie title Sports in Sweden | ||
"Bandy": 40 | ||
"Ice-Hockey": 80 | ||
"Football": 90 | ||
` | ||
pie title Sports in Sweden | ||
"Bandy" : 40 | ||
"Ice-Hockey" : 80 | ||
"Football" : 90 | ||
`, | ||
{} | ||
); | ||
cy.get('svg'); | ||
}); | ||
|
||
it('should render a simple pie diagram with long labels', () => { | ||
imgSnapshotTest( | ||
`pie title NETFLIX | ||
"Time spent looking for movie": 90 | ||
"Time spent watching it": 10 | ||
` | ||
pie title NETFLIX | ||
"Time spent looking for movie" : 90 | ||
"Time spent watching it" : 10 | ||
`, | ||
{} | ||
); | ||
cy.get('svg'); | ||
}); | ||
|
||
it('should render a simple pie diagram with capital letters for labels', () => { | ||
imgSnapshotTest( | ||
`pie title What Voldemort doesn't have? | ||
"FRIENDS": 2 | ||
"FAMILY": 3 | ||
"NOSE": 45 | ||
` | ||
pie title What Voldemort doesn't have? | ||
"FRIENDS" : 2 | ||
"FAMILY" : 3 | ||
"NOSE" : 45 | ||
`, | ||
{} | ||
); | ||
cy.get('svg'); | ||
}); | ||
|
||
it('should render a pie diagram when useMaxWidth is true (default)', () => { | ||
renderGraph( | ||
` | ||
pie title Sports in Sweden | ||
"Bandy" : 40 | ||
"Ice-Hockey" : 80 | ||
"Football" : 90 | ||
`pie title Sports in Sweden | ||
"Bandy": 40 | ||
"Ice-Hockey": 80 | ||
"Football": 90 | ||
`, | ||
{ pie: { useMaxWidth: true } } | ||
); | ||
cy.get('svg').should((svg) => { | ||
expect(svg).to.have.attr('width', '100%'); | ||
// expect(svg).to.have.attr('height'); | ||
// const height = parseFloat(svg.attr('height')); | ||
// expect(height).to.eq(450); | ||
const style = svg.attr('style'); | ||
expect(style).to.match(/^max-width: [\d.]+px;$/); | ||
const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join('')); | ||
expect(maxWidthValue).to.eq(984); | ||
}); | ||
}); | ||
|
||
it('should render a pie diagram when useMaxWidth is false', () => { | ||
renderGraph( | ||
` | ||
pie title Sports in Sweden | ||
"Bandy" : 40 | ||
"Ice-Hockey" : 80 | ||
"Football" : 90 | ||
`pie title Sports in Sweden | ||
"Bandy": 40 | ||
"Ice-Hockey": 80 | ||
"Football": 90 | ||
`, | ||
{ pie: { useMaxWidth: false } } | ||
); | ||
cy.get('svg').should((svg) => { | ||
// const height = parseFloat(svg.attr('height')); | ||
const width = parseFloat(svg.attr('width')); | ||
// expect(height).to.eq(450); | ||
expect(width).to.eq(984); | ||
expect(svg).to.not.have.attr('style'); | ||
}); | ||
}); | ||
it('should render a pie diagram when textPosition is set', () => { | ||
|
||
it('should render a pie diagram when textPosition is setted', () => { | ||
imgSnapshotTest( | ||
` | ||
pie | ||
"Dogs": 50 | ||
"Cats": 25 | ||
`, | ||
`pie | ||
"Dogs": 50 | ||
"Cats": 25 | ||
`, | ||
{ logLevel: 1, pie: { textPosition: 0.9 } } | ||
); | ||
cy.get('svg'); | ||
}); | ||
|
||
it('should render a pie diagram with showData', () => { | ||
imgSnapshotTest( | ||
`pie showData | ||
"Dogs": 50 | ||
"Cats": 25 | ||
` | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.