feat: add accessibility title and description to pie chart

* Reuse the title as the title element
* Add description to the parser and then render
This commit is contained in:
Cory Gwin
2022-02-18 02:37:43 +00:00
committed by GitHub
parent 9110bdfb5d
commit 0b815c7782
7 changed files with 84 additions and 1 deletions

View File

@@ -62,6 +62,37 @@ pie
expect(title).toBe('a 60/40 pie');
});
it('should handle simple pie without an acc description', function () {
const res = pie.parser.parse(`pie title a neat chart
"ash" : 60
"bat" : 40
`);
const sections = pieDb.getSections();
const title = pieDb.getTitle();
const description = pieDb.getAccDescription();
const section1 = sections['ash'];
expect(section1).toBe(60);
expect(title).toBe('a neat chart');
expect(description).toBe('');
});
it('should handle simple pie with an acc description', function () {
const res = pie.parser.parse(`pie title a neat chart
accDescription a neat description
"ash" : 60
"bat" : 40
`);
const sections = pieDb.getSections();
const title = pieDb.getTitle();
const description = pieDb.getAccDescription();
const section1 = sections['ash'];
expect(section1).toBe(60);
expect(title).toBe('a neat chart');
expect(description).toBe('a neat description');
});
it('should handle simple pie with positive decimal', function () {
const res = pie.parser.parse(`pie
"ash" : 60.67