use camelCase

This commit is contained in:
Ashley Engelund (weedySeaDragon @ github) 2022-11-27 19:17:37 -08:00
parent 6044e9e9e8
commit 2bf753a769
2 changed files with 49 additions and 49 deletions

View File

@ -8,16 +8,16 @@ describe('accessibility', () => {
describe('setA11yDiagramInfo', () => { describe('setA11yDiagramInfo', () => {
it('sets the aria-roledescription to the diagram type', () => { it('sets the aria-roledescription to the diagram type', () => {
// @ts-ignore Required to easily handle the d3 select types // @ts-ignore Required to easily handle the d3 select types
const svg_attr_spy = vi.spyOn(fauxSvgNode, 'attr').mockReturnValue(fauxSvgNode); const svgAttrSpy = vi.spyOn(fauxSvgNode, 'attr').mockReturnValue(fauxSvgNode);
setA11yDiagramInfo(fauxSvgNode, 'flowchart'); setA11yDiagramInfo(fauxSvgNode, 'flowchart');
expect(svg_attr_spy).toHaveBeenCalledWith('aria-roledescription', 'flowchart'); expect(svgAttrSpy).toHaveBeenCalledWith('aria-roledescription', 'flowchart');
}); });
it('does nothing if the diagram type is empty', () => { it('does nothing if the diagram type is empty', () => {
// @ts-ignore Required to easily handle the d3 select types // @ts-ignore Required to easily handle the d3 select types
const svg_attr_spy = vi.spyOn(fauxSvgNode, 'attr').mockReturnValue(fauxSvgNode); const svgAttrSpy = vi.spyOn(fauxSvgNode, 'attr').mockReturnValue(fauxSvgNode);
setA11yDiagramInfo(fauxSvgNode, ''); setA11yDiagramInfo(fauxSvgNode, '');
expect(svg_attr_spy).not.toHaveBeenCalled(); expect(svgAttrSpy).not.toHaveBeenCalled();
}); });
}); });
@ -29,9 +29,9 @@ describe('accessibility', () => {
const noInsertSvg = { const noInsertSvg = {
attr: vi.fn(), attr: vi.fn(),
}; };
const noInsert_attr_spy = vi.spyOn(noInsertSvg, 'attr').mockReturnValue(noInsertSvg); const noInsertAttrSpy = vi.spyOn(noInsertSvg, 'attr').mockReturnValue(noInsertSvg);
addSVGa11yTitleDescription(noInsertSvg, 'some title', 'some desc', givenId); addSVGa11yTitleDescription(noInsertSvg, 'some title', 'some desc', givenId);
expect(noInsert_attr_spy).not.toHaveBeenCalled(); expect(noInsertAttrSpy).not.toHaveBeenCalled();
}); });
// ---------------- // ----------------
@ -44,9 +44,9 @@ describe('accessibility', () => {
givenId: string givenId: string
) { ) {
// @ts-ignore Required to easily handle the d3 select types // @ts-ignore Required to easily handle the d3 select types
const svg_attr_spy = vi.spyOn(svgD3Node, 'attr').mockReturnValue(svgD3Node); const svgAttrSpy = vi.spyOn(svgD3Node, 'attr').mockReturnValue(svgD3Node);
addSVGa11yTitleDescription(svgD3Node, title, desc, givenId); addSVGa11yTitleDescription(svgD3Node, title, desc, givenId);
expect(svg_attr_spy).toHaveBeenCalledWith('aria-labelledby', `chart-title-${givenId}`); expect(svgAttrSpy).toHaveBeenCalledWith('aria-labelledby', `chart-title-${givenId}`);
} }
function expectAriaDescribedByIsDescId( function expectAriaDescribedByIsDescId(
@ -56,9 +56,9 @@ describe('accessibility', () => {
givenId: string givenId: string
) { ) {
// @ts-ignore Required to easily handle the d3 select types // @ts-ignore Required to easily handle the d3 select types
const svg_attr_spy = vi.spyOn(svgD3Node, 'attr').mockReturnValue(svgD3Node); const svgAttrSpy = vi.spyOn(svgD3Node, 'attr').mockReturnValue(svgD3Node);
addSVGa11yTitleDescription(svgD3Node, title, desc, givenId); addSVGa11yTitleDescription(svgD3Node, title, desc, givenId);
expect(svg_attr_spy).toHaveBeenCalledWith('aria-describedby', `chart-desc-${givenId}`); expect(svgAttrSpy).toHaveBeenCalledWith('aria-describedby', `chart-desc-${givenId}`);
} }
function a11yTitleTagInserted( function a11yTitleTagInserted(
@ -90,16 +90,16 @@ describe('accessibility', () => {
expectedPrefix: string, expectedPrefix: string,
expectedText: string | null | undefined expectedText: string | null | undefined
) { ) {
const faux_insertedD3 = new MockedD3(); const fauxInsertedD3 = new MockedD3();
const svg_insert_spy = vi.spyOn(fauxSvgNode, 'insert').mockReturnValue(faux_insertedD3); const svgInsertSpy = vi.spyOn(fauxSvgNode, 'insert').mockReturnValue(fauxInsertedD3);
// @ts-ignore Required to easily handle the d3 select types // @ts-ignore Required to easily handle the d3 select types
const title_attr_spy = vi.spyOn(faux_insertedD3, 'attr').mockReturnValue(faux_insertedD3); const titleAttrSpy = vi.spyOn(fauxInsertedD3, 'attr').mockReturnValue(fauxInsertedD3);
const title_text_spy = vi.spyOn(faux_insertedD3, 'text'); const titleTextSpy = vi.spyOn(fauxInsertedD3, 'text');
addSVGa11yTitleDescription(fauxSvgNode, title, desc, givenId); addSVGa11yTitleDescription(fauxSvgNode, title, desc, givenId);
expect(svg_insert_spy).toHaveBeenCalledWith(expectedPrefix, ':first-child'); expect(svgInsertSpy).toHaveBeenCalledWith(expectedPrefix, ':first-child');
expect(title_attr_spy).toHaveBeenCalledWith('id', `chart-${expectedPrefix}-${givenId}`); expect(titleAttrSpy).toHaveBeenCalledWith('id', `chart-${expectedPrefix}-${givenId}`);
expect(title_text_spy).toHaveBeenNthCalledWith(callNumber, expectedText); expect(titleTextSpy).toHaveBeenNthCalledWith(callNumber, expectedText);
} }
// ---------------- // ----------------
@ -135,9 +135,9 @@ describe('accessibility', () => {
it('no aria-describedby is set', () => { it('no aria-describedby is set', () => {
// @ts-ignore Required to easily handle the d3 select types // @ts-ignore Required to easily handle the d3 select types
const svg_attr_spy = vi.spyOn(fauxSvgNode, 'attr').mockReturnValue(fauxSvgNode); const svgAttrSpy = vi.spyOn(fauxSvgNode, 'attr').mockReturnValue(fauxSvgNode);
addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId); addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId);
expect(svg_attr_spy).not.toHaveBeenCalledWith('aria-describedby', expect.anything()); expect(svgAttrSpy).not.toHaveBeenCalledWith('aria-describedby', expect.anything());
}); });
it('inserts a title tag as the first child with the text set to the accTitle given', () => { it('inserts a title tag as the first child with the text set to the accTitle given', () => {
@ -145,10 +145,10 @@ describe('accessibility', () => {
}); });
it('no description tag is inserted', () => { it('no description tag is inserted', () => {
const faux_title = new MockedD3(); const fauxTitle = new MockedD3();
const svg_insert_spy = vi.spyOn(fauxSvgNode, 'insert').mockReturnValue(faux_title); const svgInsertSpy = vi.spyOn(fauxSvgNode, 'insert').mockReturnValue(fauxTitle);
addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId); addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId);
expect(svg_insert_spy).not.toHaveBeenCalledWith('desc', ':first-child'); expect(svgInsertSpy).not.toHaveBeenCalledWith('desc', ':first-child');
}); });
}); });
}); });
@ -161,16 +161,16 @@ describe('accessibility', () => {
it('no aria-labelledby is set', () => { it('no aria-labelledby is set', () => {
// @ts-ignore Required to easily handle the d3 select types // @ts-ignore Required to easily handle the d3 select types
const svg_attr_spy = vi.spyOn(fauxSvgNode, 'attr').mockReturnValue(fauxSvgNode); const svgAttrSpy = vi.spyOn(fauxSvgNode, 'attr').mockReturnValue(fauxSvgNode);
addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId); addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId);
expect(svg_attr_spy).not.toHaveBeenCalledWith('aria-labelledby', expect.anything()); expect(svgAttrSpy).not.toHaveBeenCalledWith('aria-labelledby', expect.anything());
}); });
it('no title tag inserted', () => { it('no title tag inserted', () => {
const faux_title = new MockedD3(); const fauxTitle = new MockedD3();
const svg_insert_spy = vi.spyOn(fauxSvgNode, 'insert').mockReturnValue(faux_title); const svgInsertSpy = vi.spyOn(fauxSvgNode, 'insert').mockReturnValue(fauxTitle);
addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId); addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId);
expect(svg_insert_spy).not.toHaveBeenCalledWith('title', ':first-child'); expect(svgInsertSpy).not.toHaveBeenCalledWith('title', ':first-child');
}); });
it('sets aria-describedby to the description id inserted as a child', () => { it('sets aria-describedby to the description id inserted as a child', () => {
@ -187,30 +187,30 @@ describe('accessibility', () => {
it('no aria-labelledby is set', () => { it('no aria-labelledby is set', () => {
// @ts-ignore Required to easily handle the d3 select types // @ts-ignore Required to easily handle the d3 select types
const svg_attr_spy = vi.spyOn(fauxSvgNode, 'attr').mockReturnValue(fauxSvgNode); const svgAttrSpy = vi.spyOn(fauxSvgNode, 'attr').mockReturnValue(fauxSvgNode);
addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId); addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId);
expect(svg_attr_spy).not.toHaveBeenCalledWith('aria-labelledby', expect.anything()); expect(svgAttrSpy).not.toHaveBeenCalledWith('aria-labelledby', expect.anything());
}); });
it('no aria-describedby is set', () => { it('no aria-describedby is set', () => {
// @ts-ignore Required to easily handle the d3 select types // @ts-ignore Required to easily handle the d3 select types
const svg_attr_spy = vi.spyOn(fauxSvgNode, 'attr').mockReturnValue(fauxSvgNode); const svgAttrSpy = vi.spyOn(fauxSvgNode, 'attr').mockReturnValue(fauxSvgNode);
addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId); addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId);
expect(svg_attr_spy).not.toHaveBeenCalledWith('aria-describedby', expect.anything()); expect(svgAttrSpy).not.toHaveBeenCalledWith('aria-describedby', expect.anything());
}); });
it('no title tag inserted', () => { it('no title tag inserted', () => {
const faux_title = new MockedD3(); const fauxTitle = new MockedD3();
const svg_insert_spy = vi.spyOn(fauxSvgNode, 'insert').mockReturnValue(faux_title); const svgInsertSpy = vi.spyOn(fauxSvgNode, 'insert').mockReturnValue(fauxTitle);
addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId); addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId);
expect(svg_insert_spy).not.toHaveBeenCalledWith('title', ':first-child'); expect(svgInsertSpy).not.toHaveBeenCalledWith('title', ':first-child');
}); });
it('no description tag inserted', () => { it('no description tag inserted', () => {
const faux_desc = new MockedD3(); const fauxDesc = new MockedD3();
const svg_insert_spy = vi.spyOn(fauxSvgNode, 'insert').mockReturnValue(faux_desc); const svgInsertSpy = vi.spyOn(fauxSvgNode, 'insert').mockReturnValue(fauxDesc);
addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId); addSVGa11yTitleDescription(fauxSvgNode, a11yTitle, a11yDesc, givenId);
expect(svg_insert_spy).not.toHaveBeenCalledWith('desc', ':first-child'); expect(svgInsertSpy).not.toHaveBeenCalledWith('desc', ':first-child');
}); });
}); });
}); });

View File

@ -364,41 +364,41 @@ describe('when inserting titles', function () {
}); });
it('does nothing if the title is empty', function () { it('does nothing if the title is empty', function () {
const svg_append_spy = vi.spyOn(svg, 'append'); const svgAppendSpy = vi.spyOn(svg, 'append');
utils.insertTitle(svg, 'testClass', 0, ''); utils.insertTitle(svg, 'testClass', 0, '');
expect(svg_append_spy).not.toHaveBeenCalled(); expect(svgAppendSpy).not.toHaveBeenCalled();
}); });
it('appends the title as a text item with the given title text', function () { it('appends the title as a text item with the given title text', function () {
const svg_append_spy = vi.spyOn(svg, 'append').mockReturnValue(fauxTitle); const svgAppendSpy = vi.spyOn(svg, 'append').mockReturnValue(fauxTitle);
const title_text_spy = vi.spyOn(fauxTitle, 'text'); const titleTextSpy = vi.spyOn(fauxTitle, 'text');
utils.insertTitle(svg, 'testClass', 5, 'test title'); utils.insertTitle(svg, 'testClass', 5, 'test title');
expect(svg_append_spy).toHaveBeenCalled(); expect(svgAppendSpy).toHaveBeenCalled();
expect(title_text_spy).toHaveBeenCalledWith('test title'); expect(titleTextSpy).toHaveBeenCalledWith('test title');
}); });
it('x value is the bounds x position + half of the bounds width', () => { it('x value is the bounds x position + half of the bounds width', () => {
vi.spyOn(svg, 'append').mockReturnValue(fauxTitle); vi.spyOn(svg, 'append').mockReturnValue(fauxTitle);
const title_attr_spy = vi.spyOn(fauxTitle, 'attr'); const titleAttrSpy = vi.spyOn(fauxTitle, 'attr');
utils.insertTitle(svg, 'testClass', 5, 'test title'); utils.insertTitle(svg, 'testClass', 5, 'test title');
expect(title_attr_spy).toHaveBeenCalledWith('x', 10 + 100 / 2); expect(titleAttrSpy).toHaveBeenCalledWith('x', 10 + 100 / 2);
}); });
it('y value is the negative of given title top margin', () => { it('y value is the negative of given title top margin', () => {
vi.spyOn(svg, 'append').mockReturnValue(fauxTitle); vi.spyOn(svg, 'append').mockReturnValue(fauxTitle);
const title_attr_spy = vi.spyOn(fauxTitle, 'attr'); const titleAttrSpy = vi.spyOn(fauxTitle, 'attr');
utils.insertTitle(svg, 'testClass', 5, 'test title'); utils.insertTitle(svg, 'testClass', 5, 'test title');
expect(title_attr_spy).toHaveBeenCalledWith('y', -5); expect(titleAttrSpy).toHaveBeenCalledWith('y', -5);
}); });
it('class is the given css class', () => { it('class is the given css class', () => {
vi.spyOn(svg, 'append').mockReturnValue(fauxTitle); vi.spyOn(svg, 'append').mockReturnValue(fauxTitle);
const title_attr_spy = vi.spyOn(fauxTitle, 'attr'); const titleAttrSpy = vi.spyOn(fauxTitle, 'attr');
utils.insertTitle(svg, 'testClass', 5, 'test title'); utils.insertTitle(svg, 'testClass', 5, 'test title');
expect(title_attr_spy).toHaveBeenCalledWith('class', 'testClass'); expect(titleAttrSpy).toHaveBeenCalledWith('class', 'testClass');
}); });
}); });