diff --git a/__tests__/src/ariaPropsMaps-test.js b/__tests__/src/ariaPropsMaps-test.js index 92cc60bb..45414617 100644 --- a/__tests__/src/ariaPropsMaps-test.js +++ b/__tests__/src/ariaPropsMaps-test.js @@ -2,118 +2,74 @@ import expect from 'expect'; import ariaPropsMap from '../../src/ariaPropsMap'; import rolesMap from '../../src/rolesMap'; +const entriesList = [ + ['aria-activedescendant', {'type': 'id'}], + ['aria-atomic', {'type': 'boolean'}], + ['aria-autocomplete', {'type': 'token','values': ['inline','list','both','none']}], + ["aria-braillelabel", {"type": "string"}], + ["aria-brailleroledescription", {"type": "string"}], + ['aria-busy', {'type': 'boolean'}], + ['aria-checked', {'type': 'tristate'}], + ['aria-colcount', {type: 'integer',}], + ['aria-colindex', {type: 'integer',}], + ['aria-colspan', {type: 'integer',}], + ['aria-controls', {'type': 'idlist'}], + ['aria-current', {type: 'token',values: ['page','step','location','date','time',true,false,],}], + ['aria-describedby', {'type': 'idlist'}], + ['aria-description', {'type': 'string'}], + ['aria-details', {'type': 'id'}], + ['aria-disabled', {'type': 'boolean'}], + ['aria-dropeffect', {'type': 'tokenlist','values': ['copy','execute','link','move','none','popup']}], + ['aria-errormessage', {'type': 'id'}], + ['aria-expanded', {'type': 'boolean','allowundefined': true}], + ['aria-flowto', {'type': 'idlist'}], + ['aria-grabbed', {'type': 'boolean','allowundefined': true}], + ['aria-haspopup', {'type': 'token','values': [false,true,'menu','listbox','tree','grid','dialog']}], + ['aria-hidden', {'type': 'boolean','allowundefined': true}], + ['aria-invalid', {'type': 'token','values': ['grammar',false,'spelling',true]}], + ['aria-keyshortcuts', {type: 'string',}], + ['aria-label', {'type': 'string'}], + ['aria-labelledby', {'type': 'idlist'}], + ['aria-level', {'type': 'integer'}], + ['aria-live', {'type': 'token','values': ['assertive','off','polite']}], + ['aria-modal', {type: 'boolean',}], + ['aria-multiline', {'type': 'boolean'}], + ['aria-multiselectable', {'type': 'boolean'}], + ['aria-orientation', {'type': 'token','values': ['vertical','undefined','horizontal']}], + ['aria-owns', {'type': 'idlist'}], + ['aria-placeholder', {type: 'string',}], + ['aria-posinset', {'type': 'integer'}], + ['aria-pressed', {'type': 'tristate'}], + ['aria-readonly', {'type': 'boolean'}], + ['aria-relevant', {'type': 'tokenlist','values': ['additions','all','removals','text',]}], + ['aria-required', {'type': 'boolean'}], + ['aria-roledescription', {type: 'string',}], + ['aria-rowcount', {type: 'integer',}], + ['aria-rowindex', {type: 'integer',}], + ['aria-rowspan', {type: 'integer',}], + ['aria-selected', {'type': 'boolean','allowundefined': true}], + ['aria-setsize', {'type': 'integer'}], + ['aria-sort', {'type': 'token','values': ['ascending','descending','none','other']}], + ['aria-valuemax', {'type': 'number'}], + ['aria-valuemin', {'type': 'number'}], + ['aria-valuenow', {'type': 'number'}], + ['aria-valuetext', {'type': 'string'}], +]; + describe('ariaPropsMap API', function () { - it('entries', function () { - expect(ariaPropsMap.entries()).toEqual( - expect.arrayContaining( - [ - ['aria-activedescendant', {'type': 'id'}], - ['aria-atomic', {'type': 'boolean'}], - ['aria-autocomplete', {'type': 'token','values': ['inline','list','both','none']}], - ['aria-busy', {'type': 'boolean'}], - ['aria-checked', {'type': 'tristate'}], - ['aria-colcount', {type: 'integer',}], - ['aria-colindex', {type: 'integer',}], - ['aria-colspan', {type: 'integer',}], - ['aria-controls', {'type': 'idlist'}], - ['aria-current', {type: 'token',values: ['page','step','location','date','time',true,false,],}], - ['aria-describedby', {'type': 'idlist'}], - ['aria-details', {'type': 'id'}], - ['aria-disabled', {'type': 'boolean'}], - ['aria-dropeffect', {'type': 'tokenlist','values': ['copy','execute','link','move','none','popup']}], - ['aria-errormessage', {'type': 'id'}], - ['aria-expanded', {'type': 'boolean','allowundefined': true}], - ['aria-flowto', {'type': 'idlist'}], - ['aria-grabbed', {'type': 'boolean','allowundefined': true}], - ['aria-haspopup', {'type': 'token','values': [false,true,'menu','listbox','tree','grid','dialog']}], - ['aria-hidden', {'type': 'boolean','allowundefined': true}], - ['aria-invalid', {'type': 'token','values': ['grammar',false,'spelling',true]}], - ['aria-keyshortcuts', {type: 'string',}], - ['aria-label', {'type': 'string'}], - ['aria-labelledby', {'type': 'idlist'}], - ['aria-level', {'type': 'integer'}], - ['aria-live', {'type': 'token','values': ['assertive','off','polite']}], - ['aria-modal', {type: 'boolean',}], - ['aria-multiline', {'type': 'boolean'}], - ['aria-multiselectable', {'type': 'boolean'}], - ['aria-orientation', {'type': 'token','values': ['vertical','undefined','horizontal']}], - ['aria-owns', {'type': 'idlist'}], - ['aria-placeholder', {type: 'string',}], - ['aria-posinset', {'type': 'integer'}], - ['aria-pressed', {'type': 'tristate'}], - ['aria-readonly', {'type': 'boolean'}], - ['aria-relevant', {'type': 'tokenlist','values': ['additions','all','removals','text',]}], - ['aria-required', {'type': 'boolean'}], - ['aria-roledescription', {type: 'string',}], - ['aria-rowcount', {type: 'integer',}], - ['aria-rowindex', {type: 'integer',}], - ['aria-rowspan', {type: 'integer',}], - ['aria-selected', {'type': 'boolean','allowundefined': true}], - ['aria-setsize', {'type': 'integer'}], - ['aria-sort', {'type': 'token','values': ['ascending','descending','none','other']}], - ['aria-valuemax', {'type': 'number'}], - ['aria-valuemin', {'type': 'number'}], - ['aria-valuenow', {'type': 'number'}], - ['aria-valuetext', {'type': 'string'}], - ], - ), - ); - expect([...ariaPropsMap.entries()]).toEqual( - expect.arrayContaining( - [ - ['aria-activedescendant', {'type': 'id'}], - ['aria-atomic', {'type': 'boolean'}], - ['aria-autocomplete', {'type': 'token','values': ['inline','list','both','none']}], - ['aria-busy', {'type': 'boolean'}], - ['aria-checked', {'type': 'tristate'}], - ['aria-colcount', {type: 'integer',}], - ['aria-colindex', {type: 'integer',}], - ['aria-colspan', {type: 'integer',}], - ['aria-controls', {'type': 'idlist'}], - ['aria-current', {type: 'token',values: ['page','step','location','date','time',true,false,],}], - ['aria-describedby', {'type': 'idlist'}], - ['aria-details', {'type': 'id'}], - ['aria-disabled', {'type': 'boolean'}], - ['aria-dropeffect', {'type': 'tokenlist','values': ['copy','execute','link','move','none','popup']}], - ['aria-errormessage', {'type': 'id'}], - ['aria-expanded', {'type': 'boolean','allowundefined': true}], - ['aria-flowto', {'type': 'idlist'}], - ['aria-grabbed', {'type': 'boolean','allowundefined': true}], - ['aria-haspopup', {'type': 'token','values': [false,true,'menu','listbox','tree','grid','dialog']}], - ['aria-hidden', {'type': 'boolean','allowundefined': true}], - ['aria-invalid', {'type': 'token','values': ['grammar',false,'spelling',true]}], - ['aria-keyshortcuts', {type: 'string',}], - ['aria-label', {'type': 'string'}], - ['aria-labelledby', {'type': 'idlist'}], - ['aria-level', {'type': 'integer'}], - ['aria-live', {'type': 'token','values': ['assertive','off','polite']}], - ['aria-modal', {type: 'boolean',}], - ['aria-multiline', {'type': 'boolean'}], - ['aria-multiselectable', {'type': 'boolean'}], - ['aria-orientation', {'type': 'token','values': ['vertical','undefined','horizontal']}], - ['aria-owns', {'type': 'idlist'}], - ['aria-placeholder', {type: 'string',}], - ['aria-posinset', {'type': 'integer'}], - ['aria-pressed', {'type': 'tristate'}], - ['aria-readonly', {'type': 'boolean'}], - ['aria-relevant', {'type': 'tokenlist','values': ['additions','all','removals','text',]}], - ['aria-required', {'type': 'boolean'}], - ['aria-roledescription', {type: 'string',}], - ['aria-rowcount', {type: 'integer',}], - ['aria-rowindex', {type: 'integer',}], - ['aria-rowspan', {type: 'integer',}], - ['aria-selected', {'type': 'boolean','allowundefined': true}], - ['aria-setsize', {'type': 'integer'}], - ['aria-sort', {'type': 'token','values': ['ascending','descending','none','other']}], - ['aria-valuemax', {'type': 'number'}], - ['aria-valuemin', {'type': 'number'}], - ['aria-valuenow', {'type': 'number'}], - ['aria-valuetext', {'type': 'string'}], - ], - ), - ); + describe('entries()', function () { + test.each(ariaPropsMap.entries())('Testing prop: %s', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); + test.each([...ariaPropsMap.entries()])('Testing prop: %s', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); - it('forEach', function () { + describe('forEach()', function () { const output = []; let context; ariaPropsMap.forEach((value, key, map) => { @@ -122,342 +78,50 @@ describe('ariaPropsMap API', function () { context = map; } }); - expect(output).toEqual( - expect.arrayContaining( - [ - ['aria-activedescendant', {'type': 'id'}], - ['aria-atomic', {'type': 'boolean'}], - ['aria-autocomplete', {'type': 'token','values': ['inline','list','both','none']}], - ['aria-busy', {'type': 'boolean'}], - ['aria-checked', {'type': 'tristate'}], - ['aria-colcount', {type: 'integer',}], - ['aria-colindex', {type: 'integer',}], - ['aria-colspan', {type: 'integer',}], - ['aria-controls', {'type': 'idlist'}], - ['aria-current', {type: 'token',values: ['page','step','location','date','time',true,false,],}], - ['aria-describedby', {'type': 'idlist'}], - ['aria-details', {'type': 'id'}], - ['aria-disabled', {'type': 'boolean'}], - ['aria-dropeffect', {'type': 'tokenlist','values': ['copy','execute','link','move','none','popup']}], - ['aria-errormessage', {'type': 'id'}], - ['aria-expanded', {'type': 'boolean','allowundefined': true}], - ['aria-flowto', {'type': 'idlist'}], - ['aria-grabbed', {'type': 'boolean','allowundefined': true}], - ['aria-haspopup', {'type': 'token','values': [false,true,'menu','listbox','tree','grid','dialog']}], - ['aria-hidden', {'type': 'boolean','allowundefined': true}], - ['aria-invalid', {'type': 'token','values': ['grammar',false,'spelling',true]}], - ['aria-keyshortcuts', {type: 'string',}], - ['aria-label', {'type': 'string'}], - ['aria-labelledby', {'type': 'idlist'}], - ['aria-level', {'type': 'integer'}], - ['aria-live', {'type': 'token','values': ['assertive','off','polite']}], - ['aria-modal', {type: 'boolean',}], - ['aria-multiline', {'type': 'boolean'}], - ['aria-multiselectable', {'type': 'boolean'}], - ['aria-orientation', {'type': 'token','values': ['vertical','undefined','horizontal']}], - ['aria-owns', {'type': 'idlist'}], - ['aria-placeholder', {type: 'string',}], - ['aria-posinset', {'type': 'integer'}], - ['aria-pressed', {'type': 'tristate'}], - ['aria-readonly', {'type': 'boolean'}], - ['aria-relevant', {'type': 'tokenlist','values': ['additions','all','removals','text',]}], - ['aria-required', {'type': 'boolean'}], - ['aria-roledescription', {type: 'string',}], - ['aria-rowcount', {type: 'integer',}], - ['aria-rowindex', {type: 'integer',}], - ['aria-rowspan', {type: 'integer',}], - ['aria-selected', {'type': 'boolean','allowundefined': true}], - ['aria-setsize', {'type': 'integer'}], - ['aria-sort', {'type': 'token','values': ['ascending','descending','none','other']}], - ['aria-valuemax', {'type': 'number'}], - ['aria-valuemin', {'type': 'number'}], - ['aria-valuenow', {'type': 'number'}], - ['aria-valuetext', {'type': 'string'}], - ], - ), - ); - expect(context).toEqual( - expect.arrayContaining( - [ - ['aria-activedescendant', {'type': 'id'}], - ['aria-atomic', {'type': 'boolean'}], - ['aria-autocomplete', {'type': 'token','values': ['inline','list','both','none']}], - ['aria-busy', {'type': 'boolean'}], - ['aria-checked', {'type': 'tristate'}], - ['aria-colcount', {type: 'integer',}], - ['aria-colindex', {type: 'integer',}], - ['aria-colspan', {type: 'integer',}], - ['aria-controls', {'type': 'idlist'}], - ['aria-current', {type: 'token',values: ['page','step','location','date','time',true,false,],}], - ['aria-describedby', {'type': 'idlist'}], - ['aria-details', {'type': 'id'}], - ['aria-disabled', {'type': 'boolean'}], - ['aria-dropeffect', {'type': 'tokenlist','values': ['copy','execute','link','move','none','popup']}], - ['aria-errormessage', {'type': 'id'}], - ['aria-expanded', {'type': 'boolean','allowundefined': true}], - ['aria-flowto', {'type': 'idlist'}], - ['aria-grabbed', {'type': 'boolean','allowundefined': true}], - ['aria-haspopup', {'type': 'token','values': [false,true,'menu','listbox','tree','grid','dialog']}], - ['aria-hidden', {'type': 'boolean','allowundefined': true}], - ['aria-invalid', {'type': 'token','values': ['grammar',false,'spelling',true]}], - ['aria-keyshortcuts', {type: 'string',}], - ['aria-label', {'type': 'string'}], - ['aria-labelledby', {'type': 'idlist'}], - ['aria-level', {'type': 'integer'}], - ['aria-live', {'type': 'token','values': ['assertive','off','polite']}], - ['aria-modal', {type: 'boolean',}], - ['aria-multiline', {'type': 'boolean'}], - ['aria-multiselectable', {'type': 'boolean'}], - ['aria-orientation', {'type': 'token','values': ['vertical','undefined','horizontal']}], - ['aria-owns', {'type': 'idlist'}], - ['aria-placeholder', {type: 'string',}], - ['aria-posinset', {'type': 'integer'}], - ['aria-pressed', {'type': 'tristate'}], - ['aria-readonly', {'type': 'boolean'}], - ['aria-relevant', {'type': 'tokenlist','values': ['additions','all','removals','text',]}], - ['aria-required', {'type': 'boolean'}], - ['aria-roledescription', {type: 'string',}], - ['aria-rowcount', {type: 'integer',}], - ['aria-rowindex', {type: 'integer',}], - ['aria-rowspan', {type: 'integer',}], - ['aria-selected', {'type': 'boolean','allowundefined': true}], - ['aria-setsize', {'type': 'integer'}], - ['aria-sort', {'type': 'token','values': ['ascending','descending','none','other']}], - ['aria-valuemax', {'type': 'number'}], - ['aria-valuemin', {'type': 'number'}], - ['aria-valuenow', {'type': 'number'}], - ['aria-valuetext', {'type': 'string'}], - ], - ), - ); + test.each(output)('Testing prop: %s', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); + test.each(context)('Testing prop: %s', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); - it('get', function () { + it('get()', function () { expect(ariaPropsMap.get('aria-label')).toBeDefined(); expect(ariaPropsMap.get('fake prop')).toBeUndefined(); }); - it('has', function () { + it('has()', function () { expect(ariaPropsMap.has('aria-label')).toEqual(true); expect(ariaPropsMap.has('fake prop')).toEqual(false); }); - it('keys', function () { - expect(ariaPropsMap.keys()).toEqual( - expect.arrayContaining( - [ - 'aria-activedescendant', - 'aria-atomic', - 'aria-autocomplete', - 'aria-busy', - 'aria-checked', - 'aria-colcount', - 'aria-colindex', - 'aria-colspan', - 'aria-controls', - 'aria-current', - 'aria-describedby', - 'aria-details', - 'aria-disabled', - 'aria-dropeffect', - 'aria-errormessage', - 'aria-expanded', - 'aria-flowto', - 'aria-grabbed', - 'aria-haspopup', - 'aria-hidden', - 'aria-invalid', - 'aria-keyshortcuts', - 'aria-label', - 'aria-labelledby', - 'aria-level', - 'aria-live', - 'aria-modal', - 'aria-multiline', - 'aria-multiselectable', - 'aria-orientation', - 'aria-owns', - 'aria-placeholder', - 'aria-posinset', - 'aria-pressed', - 'aria-readonly', - 'aria-relevant', - 'aria-required', - 'aria-roledescription', - 'aria-rowcount', - 'aria-rowindex', - 'aria-rowspan', - 'aria-selected', - 'aria-setsize', - 'aria-sort', - 'aria-valuemax', - 'aria-valuemin', - 'aria-valuenow', - 'aria-valuetext', - ], - ), - ); - expect([...ariaPropsMap.keys()]).toEqual( - expect.arrayContaining( - [ - 'aria-activedescendant', - 'aria-atomic', - 'aria-autocomplete', - 'aria-busy', - 'aria-checked', - 'aria-colcount', - 'aria-colindex', - 'aria-colspan', - 'aria-controls', - 'aria-current', - 'aria-describedby', - 'aria-details', - 'aria-disabled', - 'aria-dropeffect', - 'aria-errormessage', - 'aria-expanded', - 'aria-flowto', - 'aria-grabbed', - 'aria-haspopup', - 'aria-hidden', - 'aria-invalid', - 'aria-keyshortcuts', - 'aria-label', - 'aria-labelledby', - 'aria-level', - 'aria-live', - 'aria-modal', - 'aria-multiline', - 'aria-multiselectable', - 'aria-orientation', - 'aria-owns', - 'aria-placeholder', - 'aria-posinset', - 'aria-pressed', - 'aria-readonly', - 'aria-relevant', - 'aria-required', - 'aria-roledescription', - 'aria-rowcount', - 'aria-rowindex', - 'aria-rowspan', - 'aria-selected', - 'aria-setsize', - 'aria-sort', - 'aria-valuemax', - 'aria-valuemin', - 'aria-valuenow', - 'aria-valuetext', - ], - ), - ); + describe('keys()', function () { + const entriesKeys = entriesList.map(entry => entry[0]); + test.each(ariaPropsMap.keys())('Testing key: %o', (key) => { + expect(entriesKeys).toEqual( + expect.arrayContaining([key]), + ); + }); + test.each([...ariaPropsMap.keys()])('Testing key: %o', (key) => { + expect(entriesKeys).toEqual( + expect.arrayContaining([key]), + ); + }); }); - it('values', function () { - expect(ariaPropsMap.values()).toEqual( - expect.arrayContaining( - [ - {'type': 'id'}, - {'type': 'boolean'}, - {'type': 'token','values': ['inline','list','both','none']}, - {'type': 'boolean'}, - {'type': 'tristate'}, - {'type': 'integer',}, - {'type': 'integer',}, - {'type': 'integer',}, - {'type': 'idlist'}, - {'type': 'token',values: ['page','step','location','date','time',true,false,],}, - {'type': 'idlist'}, - {'type': 'id'}, - {'type': 'boolean'}, - {'type': 'tokenlist','values': ['copy','execute','link','move','none','popup']}, - {'type': 'id'}, - {'type': 'boolean','allowundefined': true}, - {'type': 'idlist'}, - {'type': 'boolean','allowundefined': true}, - {'type': 'token','values': [false,true,'menu','listbox','tree','grid','dialog']}, - {'type': 'boolean','allowundefined': true}, - {'type': 'token','values': ['grammar',false,'spelling',true]}, - {'type': 'string',}, - {'type': 'string'}, - {'type': 'idlist'}, - {'type': 'integer'}, - {'type': 'token','values': ['assertive','off','polite']}, - {'type': 'boolean',}, - {'type': 'boolean'}, - {'type': 'boolean'}, - {'type': 'token','values': ['vertical','undefined','horizontal']}, - {'type': 'idlist'}, - {'type': 'string',}, - {'type': 'integer'}, - {'type': 'tristate'}, - {'type': 'boolean'}, - {'type': 'tokenlist','values': ['additions','all','removals','text',]}, - {'type': 'boolean'}, - {'type': 'string',}, - {'type': 'integer',}, - {'type': 'integer',}, - {'type': 'integer',}, - {'type': 'boolean','allowundefined': true}, - {'type': 'integer'}, - {'type': 'token','values': ['ascending','descending','none','other']}, - {'type': 'number'}, - {'type': 'number'}, - {'type': 'number'}, - {'type': 'string'}, - ], - ), - ); - expect([...ariaPropsMap.values()]).toEqual( - expect.arrayContaining( - [ - {'type': 'id'}, - {'type': 'boolean'}, - {'type': 'token','values': ['inline','list','both','none']}, - {'type': 'boolean'}, - {'type': 'tristate'}, - {'type': 'integer',}, - {'type': 'integer',}, - {'type': 'integer',}, - {'type': 'idlist'}, - {'type': 'token',values: ['page','step','location','date','time',true,false,],}, - {'type': 'idlist'}, - {'type': 'id'}, - {'type': 'boolean'}, - {'type': 'tokenlist','values': ['copy','execute','link','move','none','popup']}, - {'type': 'id'}, - {'type': 'boolean','allowundefined': true}, - {'type': 'idlist'}, - {'type': 'boolean','allowundefined': true}, - {'type': 'token','values': [false,true,'menu','listbox','tree','grid','dialog']}, - {'type': 'boolean','allowundefined': true}, - {'type': 'token','values': ['grammar',false,'spelling',true]}, - {'type': 'string',}, - {'type': 'string'}, - {'type': 'idlist'}, - {'type': 'integer'}, - {'type': 'token','values': ['assertive','off','polite']}, - {'type': 'boolean',}, - {'type': 'boolean'}, - {'type': 'boolean'}, - {'type': 'token','values': ['vertical','undefined','horizontal']}, - {'type': 'idlist'}, - {'type': 'string',}, - {'type': 'integer'}, - {'type': 'tristate'}, - {'type': 'boolean'}, - {'type': 'tokenlist','values': ['additions','all','removals','text',]}, - {'type': 'boolean'}, - {'type': 'string',}, - {'type': 'integer',}, - {'type': 'integer',}, - {'type': 'integer',}, - {'type': 'boolean','allowundefined': true}, - {'type': 'integer'}, - {'type': 'token','values': ['ascending','descending','none','other']}, - {'type': 'number'}, - {'type': 'number'}, - {'type': 'number'}, - {'type': 'string'}, - ], - ), - ); + describe('values()', function () { + const entriesValues = entriesList.map(entry => entry[1]); + test.each(ariaPropsMap.values())('Testing value: %o', (value) => { + expect(entriesValues).toEqual( + expect.arrayContaining([value]), + ); + }); + test.each([...ariaPropsMap.values()])('Testing value: %o', (value) => { + expect(entriesValues).toEqual( + expect.arrayContaining([value]), + ); + }); }); }); @@ -466,122 +130,26 @@ describe('ariaPropsMap', function () { it('should have an iterator defined', function () { expect(ariaPropsMap[Symbol.iterator]).not.toBeUndefined(); }); - it('should support the spread operator', function () { - expect(ariaPropsMap.entries().length).toEqual(48); - expect([...ariaPropsMap]).toEqual( - expect.arrayContaining( - [ - ['aria-activedescendant', {'type': 'id'}], - ['aria-atomic', {'type': 'boolean'}], - ['aria-autocomplete', {'type': 'token','values': ['inline','list','both','none']}], - ['aria-busy', {'type': 'boolean'}], - ['aria-checked', {'type': 'tristate'}], - ['aria-colcount', {type: 'integer',}], - ['aria-colindex', {type: 'integer',}], - ['aria-colspan', {type: 'integer',}], - ['aria-controls', {'type': 'idlist'}], - ['aria-current', {type: 'token',values: ['page','step','location','date','time',true,false,],}], - ['aria-describedby', {'type': 'idlist'}], - ['aria-details', {'type': 'id'}], - ['aria-disabled', {'type': 'boolean'}], - ['aria-dropeffect', {'type': 'tokenlist','values': ['copy','execute','link','move','none','popup']}], - ['aria-errormessage', {'type': 'id'}], - ['aria-expanded', {'type': 'boolean','allowundefined': true}], - ['aria-flowto', {'type': 'idlist'}], - ['aria-grabbed', {'type': 'boolean','allowundefined': true}], - ['aria-haspopup', {'type': 'token','values': [false,true,'menu','listbox','tree','grid','dialog']}], - ['aria-hidden', {'type': 'boolean','allowundefined': true}], - ['aria-invalid', {'type': 'token','values': ['grammar',false,'spelling',true]}], - ['aria-keyshortcuts', {type: 'string',}], - ['aria-label', {'type': 'string'}], - ['aria-labelledby', {'type': 'idlist'}], - ['aria-level', {'type': 'integer'}], - ['aria-live', {'type': 'token','values': ['assertive','off','polite']}], - ['aria-modal', {type: 'boolean',}], - ['aria-multiline', {'type': 'boolean'}], - ['aria-multiselectable', {'type': 'boolean'}], - ['aria-orientation', {'type': 'token','values': ['vertical','undefined','horizontal']}], - ['aria-owns', {'type': 'idlist'}], - ['aria-placeholder', {type: 'string',}], - ['aria-posinset', {'type': 'integer'}], - ['aria-pressed', {'type': 'tristate'}], - ['aria-readonly', {'type': 'boolean'}], - ['aria-relevant', {'type': 'tokenlist','values': ['additions','all','removals','text',]}], - ['aria-required', {'type': 'boolean'}], - ['aria-roledescription', {type: 'string',}], - ['aria-rowcount', {type: 'integer',}], - ['aria-rowindex', {type: 'integer',}], - ['aria-rowspan', {type: 'integer',}], - ['aria-selected', {'type': 'boolean','allowundefined': true}], - ['aria-setsize', {'type': 'integer'}], - ['aria-sort', {'type': 'token','values': ['ascending','descending','none','other']}], - ['aria-valuemax', {'type': 'number'}], - ['aria-valuemin', {'type': 'number'}], - ['aria-valuenow', {'type': 'number'}], - ['aria-valuetext', {'type': 'string'}], - ], - ), - ); + describe('spread operator', function () { + it('should have a specific length', function () { + expect(ariaPropsMap.entries().length).toEqual(51); + }); + test.each([...ariaPropsMap])('Testing prop: %s', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); - it('should support the for..of pattern', function () { + describe('for..of pattern', function () { const output = []; for (const [key, value] of ariaPropsMap) { output.push([key, value]); } - expect(output).toEqual( - expect.arrayContaining( - [ - ['aria-activedescendant', {'type': 'id'}], - ['aria-atomic', {'type': 'boolean'}], - ['aria-autocomplete', {'type': 'token','values': ['inline','list','both','none']}], - ['aria-busy', {'type': 'boolean'}], - ['aria-checked', {'type': 'tristate'}], - ['aria-colcount', {type: 'integer',}], - ['aria-colindex', {type: 'integer',}], - ['aria-colspan', {type: 'integer',}], - ['aria-controls', {'type': 'idlist'}], - ['aria-current', {type: 'token',values: ['page','step','location','date','time',true,false,],}], - ['aria-describedby', {'type': 'idlist'}], - ['aria-details', {'type': 'id'}], - ['aria-disabled', {'type': 'boolean'}], - ['aria-dropeffect', {'type': 'tokenlist','values': ['copy','execute','link','move','none','popup']}], - ['aria-errormessage', {'type': 'id'}], - ['aria-expanded', {'type': 'boolean','allowundefined': true}], - ['aria-flowto', {'type': 'idlist'}], - ['aria-grabbed', {'type': 'boolean','allowundefined': true}], - ['aria-haspopup', {'type': 'token','values': [false,true,'menu','listbox','tree','grid','dialog']}], - ['aria-hidden', {'type': 'boolean','allowundefined': true}], - ['aria-invalid', {'type': 'token','values': ['grammar',false,'spelling',true]}], - ['aria-keyshortcuts', {type: 'string',}], - ['aria-label', {'type': 'string'}], - ['aria-labelledby', {'type': 'idlist'}], - ['aria-level', {'type': 'integer'}], - ['aria-live', {'type': 'token','values': ['assertive','off','polite']}], - ['aria-modal', {type: 'boolean',}], - ['aria-multiline', {'type': 'boolean'}], - ['aria-multiselectable', {'type': 'boolean'}], - ['aria-orientation', {'type': 'token','values': ['vertical','undefined','horizontal']}], - ['aria-owns', {'type': 'idlist'}], - ['aria-placeholder', {type: 'string',}], - ['aria-posinset', {'type': 'integer'}], - ['aria-pressed', {'type': 'tristate'}], - ['aria-readonly', {'type': 'boolean'}], - ['aria-relevant', {'type': 'tokenlist','values': ['additions','all','removals','text',]}], - ['aria-required', {'type': 'boolean'}], - ['aria-roledescription', {type: 'string',}], - ['aria-rowcount', {type: 'integer',}], - ['aria-rowindex', {type: 'integer',}], - ['aria-rowspan', {type: 'integer',}], - ['aria-selected', {'type': 'boolean','allowundefined': true}], - ['aria-setsize', {'type': 'integer'}], - ['aria-sort', {'type': 'token','values': ['ascending','descending','none','other']}], - ['aria-valuemax', {'type': 'number'}], - ['aria-valuemin', {'type': 'number'}], - ['aria-valuenow', {'type': 'number'}], - ['aria-valuetext', {'type': 'string'}], - ], - ), - ); + test.each(output)('Testing prop: %s', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); }); describe('props and role defintions', function () { diff --git a/__tests__/src/domMap-test.js b/__tests__/src/domMap-test.js index 72749089..1eec1f69 100644 --- a/__tests__/src/domMap-test.js +++ b/__tests__/src/domMap-test.js @@ -1,280 +1,152 @@ import expect from 'expect'; import domMap from '../../src/domMap'; +const entriesList = [ + ["a", {"reserved": false}], + ["abbr", {"reserved": false}], + ["acronym", {"reserved": false}], + ["address", {"reserved": false}], + ["applet", {"reserved": false}], + ["area", {"reserved": false}], + ["article", {"reserved": false}], + ["aside", {"reserved": false}], + ["audio", {"reserved": false}], + ["b", {"reserved": false}], + ["base", {"reserved": true}], + ["bdi", {"reserved": false}], + ["bdo", {"reserved": false}], + ["big", {"reserved": false}], + ["blink", {"reserved": false}], + ["blockquote", {"reserved": false}], + ["body", {"reserved": false}], + ["br", {"reserved": false}], + ["button", {"reserved": false}], + ["canvas", {"reserved": false}], + ["caption", {"reserved": false}], + ["center", {"reserved": false}], + ["cite", {"reserved": false}], + ["code", {"reserved": false}], + ["col", {"reserved": true}], + ["colgroup", {"reserved": true}], + ["content", {"reserved": false}], + ["data", {"reserved": false}], + ["datalist", {"reserved": false}], + ["dd", {"reserved": false}], + ["del", {"reserved": false}], + ["details", {"reserved": false}], + ["dfn", {"reserved": false}], + ["dialog", {"reserved": false}], + ["dir", {"reserved": false}], + ["div", {"reserved": false}], + ["dl", {"reserved": false}], + ["dt", {"reserved": false}], + ["em", {"reserved": false}], + ["embed", {"reserved": false}], + ["fieldset", {"reserved": false}], + ["figcaption", {"reserved": false}], + ["figure", {"reserved": false}], + ["font", {"reserved": false}], + ["footer", {"reserved": false}], + ["form", {"reserved": false}], + ["frame", {"reserved": false}], + ["frameset", {"reserved": false}], + ["h1", {"reserved": false}], + ["h2", {"reserved": false}], + ["h3", {"reserved": false}], + ["h4", {"reserved": false}], + ["h5", {"reserved": false}], + ["h6", {"reserved": false}], + ["head", {"reserved": true}], + ["header", {"reserved": false}], + ["hgroup", {"reserved": false}], + ["hr", {"reserved": false}], + ["html", {"reserved": true}], + ["i", {"reserved": false}], + ["iframe", {"reserved": false}], + ["img", {"reserved": false}], + ["input", {"reserved": false}], + ["ins", {"reserved": false}], + ["kbd", {"reserved": false}], + ["keygen", {"reserved": false}], + ["label", {"reserved": false}], + ["legend", {"reserved": false}], + ["li", {"reserved": false}], + ["link", {"reserved": true}], + ["main", {"reserved": false}], + ["map", {"reserved": false}], + ["mark", {"reserved": false}], + ["marquee", {"reserved": false}], + ["menu", {"reserved": false}], + ["menuitem", {"reserved": false}], + ["meta", {"reserved": true}], + ["meter", {"reserved": false}], + ["nav", {"reserved": false}], + ["noembed", {"reserved": true}], + ["noscript", {"reserved": true}], + ["object", {"reserved": false}], + ["ol", {"reserved": false}], + ["optgroup", {"reserved": false}], + ["option", {"reserved": false}], + ["output", {"reserved": false}], + ["p", {"reserved": false}], + ["param", {"reserved": true}], + ["picture", {"reserved": true}], + ["pre", {"reserved": false}], + ["progress", {"reserved": false}], + ["q", {"reserved": false}], + ["rp", {"reserved": false}], + ["rt", {"reserved": false}], + ["rtc", {"reserved": false}], + ["ruby", {"reserved": false}], + ["s", {"reserved": false}], + ["samp", {"reserved": false}], + ["script", {"reserved": true}], + ["section", {"reserved": false}], + ["select", {"reserved": false}], + ["small", {"reserved": false}], + ["source", {"reserved": true}], + ["spacer", {"reserved": false}], + ["span", {"reserved": false}], + ["strike", {"reserved": false}], + ["strong", {"reserved": false}], + ["style", {"reserved": true}], + ["sub", {"reserved": false}], + ["summary", {"reserved": false}], + ["sup", {"reserved": false}], + ["table", {"reserved": false}], + ["tbody", {"reserved": false}], + ["td", {"reserved": false}], + ["textarea", {"reserved": false}], + ["tfoot", {"reserved": false}], + ["th", {"reserved": false}], + ["thead", {"reserved": false}], + ["time", {"reserved": false}], + ["title", {"reserved": true}], + ["tr", {"reserved": false}], + ["track", {"reserved": true}], + ["tt", {"reserved": false}], + ["u", {"reserved": false}], + ["ul", {"reserved": false}], + ["var", {"reserved": false}], + ["video", {"reserved": false}], + ["wbr", {"reserved": false}], + ["xmp", {"reserved": false}], +]; + describe('domMap API', function () { - it('entries', function () { - expect(domMap.entries()).toEqual( - expect.arrayContaining( - [ - ["a", {"reserved": false}], - ["abbr", {"reserved": false}], - ["acronym", {"reserved": false}], - ["address", {"reserved": false}], - ["applet", {"reserved": false}], - ["area", {"reserved": false}], - ["article", {"reserved": false}], - ["aside", {"reserved": false}], - ["audio", {"reserved": false}], - ["b", {"reserved": false}], - ["base", {"reserved": true}], - ["bdi", {"reserved": false}], - ["bdo", {"reserved": false}], - ["big", {"reserved": false}], - ["blink", {"reserved": false}], - ["blockquote", {"reserved": false}], - ["body", {"reserved": false}], - ["br", {"reserved": false}], - ["button", {"reserved": false}], - ["canvas", {"reserved": false}], - ["caption", {"reserved": false}], - ["center", {"reserved": false}], - ["cite", {"reserved": false}], - ["code", {"reserved": false}], - ["col", {"reserved": true}], - ["colgroup", {"reserved": true}], - ["content", {"reserved": false}], - ["data", {"reserved": false}], - ["datalist", {"reserved": false}], - ["dd", {"reserved": false}], - ["del", {"reserved": false}], - ["details", {"reserved": false}], - ["dfn", {"reserved": false}], - ["dialog", {"reserved": false}], - ["dir", {"reserved": false}], - ["div", {"reserved": false}], - ["dl", {"reserved": false}], - ["dt", {"reserved": false}], - ["em", {"reserved": false}], - ["embed", {"reserved": false}], - ["fieldset", {"reserved": false}], - ["figcaption", {"reserved": false}], - ["figure", {"reserved": false}], - ["font", {"reserved": false}], - ["footer", {"reserved": false}], - ["form", {"reserved": false}], - ["frame", {"reserved": false}], - ["frameset", {"reserved": false}], - ["h1", {"reserved": false}], - ["h2", {"reserved": false}], - ["h3", {"reserved": false}], - ["h4", {"reserved": false}], - ["h5", {"reserved": false}], - ["h6", {"reserved": false}], - ["head", {"reserved": true}], - ["header", {"reserved": false}], - ["hgroup", {"reserved": false}], - ["hr", {"reserved": false}], - ["html", {"reserved": true}], - ["i", {"reserved": false}], - ["iframe", {"reserved": false}], - ["img", {"reserved": false}], - ["input", {"reserved": false}], - ["ins", {"reserved": false}], - ["kbd", {"reserved": false}], - ["keygen", {"reserved": false}], - ["label", {"reserved": false}], - ["legend", {"reserved": false}], - ["li", {"reserved": false}], - ["link", {"reserved": true}], - ["main", {"reserved": false}], - ["map", {"reserved": false}], - ["mark", {"reserved": false}], - ["marquee", {"reserved": false}], - ["menu", {"reserved": false}], - ["menuitem", {"reserved": false}], - ["meta", {"reserved": true}], - ["meter", {"reserved": false}], - ["nav", {"reserved": false}], - ["noembed", {"reserved": true}], - ["noscript", {"reserved": true}], - ["object", {"reserved": false}], - ["ol", {"reserved": false}], - ["optgroup", {"reserved": false}], - ["option", {"reserved": false}], - ["output", {"reserved": false}], - ["p", {"reserved": false}], - ["param", {"reserved": true}], - ["picture", {"reserved": true}], - ["pre", {"reserved": false}], - ["progress", {"reserved": false}], - ["q", {"reserved": false}], - ["rp", {"reserved": false}], - ["rt", {"reserved": false}], - ["rtc", {"reserved": false}], - ["ruby", {"reserved": false}], - ["s", {"reserved": false}], - ["samp", {"reserved": false}], - ["script", {"reserved": true}], - ["section", {"reserved": false}], - ["select", {"reserved": false}], - ["small", {"reserved": false}], - ["source", {"reserved": true}], - ["spacer", {"reserved": false}], - ["span", {"reserved": false}], - ["strike", {"reserved": false}], - ["strong", {"reserved": false}], - ["style", {"reserved": true}], - ["sub", {"reserved": false}], - ["summary", {"reserved": false}], - ["sup", {"reserved": false}], - ["table", {"reserved": false}], - ["tbody", {"reserved": false}], - ["td", {"reserved": false}], - ["textarea", {"reserved": false}], - ["tfoot", {"reserved": false}], - ["th", {"reserved": false}], - ["thead", {"reserved": false}], - ["time", {"reserved": false}], - ["title", {"reserved": true}], - ["tr", {"reserved": false}], - ["track", {"reserved": true}], - ["tt", {"reserved": false}], - ["u", {"reserved": false}], - ["ul", {"reserved": false}], - ["var", {"reserved": false}], - ["video", {"reserved": false}], - ["wbr", {"reserved": false}], - ["xmp", {"reserved": false}], - ], - ), - ); - expect([...domMap.entries()]).toEqual( - expect.arrayContaining( - [ - ["a", {"reserved": false}], - ["abbr", {"reserved": false}], - ["acronym", {"reserved": false}], - ["address", {"reserved": false}], - ["applet", {"reserved": false}], - ["area", {"reserved": false}], - ["article", {"reserved": false}], - ["aside", {"reserved": false}], - ["audio", {"reserved": false}], - ["b", {"reserved": false}], - ["base", {"reserved": true}], - ["bdi", {"reserved": false}], - ["bdo", {"reserved": false}], - ["big", {"reserved": false}], - ["blink", {"reserved": false}], - ["blockquote", {"reserved": false}], - ["body", {"reserved": false}], - ["br", {"reserved": false}], - ["button", {"reserved": false}], - ["canvas", {"reserved": false}], - ["caption", {"reserved": false}], - ["center", {"reserved": false}], - ["cite", {"reserved": false}], - ["code", {"reserved": false}], - ["col", {"reserved": true}], - ["colgroup", {"reserved": true}], - ["content", {"reserved": false}], - ["data", {"reserved": false}], - ["datalist", {"reserved": false}], - ["dd", {"reserved": false}], - ["del", {"reserved": false}], - ["details", {"reserved": false}], - ["dfn", {"reserved": false}], - ["dialog", {"reserved": false}], - ["dir", {"reserved": false}], - ["div", {"reserved": false}], - ["dl", {"reserved": false}], - ["dt", {"reserved": false}], - ["em", {"reserved": false}], - ["embed", {"reserved": false}], - ["fieldset", {"reserved": false}], - ["figcaption", {"reserved": false}], - ["figure", {"reserved": false}], - ["font", {"reserved": false}], - ["footer", {"reserved": false}], - ["form", {"reserved": false}], - ["frame", {"reserved": false}], - ["frameset", {"reserved": false}], - ["h1", {"reserved": false}], - ["h2", {"reserved": false}], - ["h3", {"reserved": false}], - ["h4", {"reserved": false}], - ["h5", {"reserved": false}], - ["h6", {"reserved": false}], - ["head", {"reserved": true}], - ["header", {"reserved": false}], - ["hgroup", {"reserved": false}], - ["hr", {"reserved": false}], - ["html", {"reserved": true}], - ["i", {"reserved": false}], - ["iframe", {"reserved": false}], - ["img", {"reserved": false}], - ["input", {"reserved": false}], - ["ins", {"reserved": false}], - ["kbd", {"reserved": false}], - ["keygen", {"reserved": false}], - ["label", {"reserved": false}], - ["legend", {"reserved": false}], - ["li", {"reserved": false}], - ["link", {"reserved": true}], - ["main", {"reserved": false}], - ["map", {"reserved": false}], - ["mark", {"reserved": false}], - ["marquee", {"reserved": false}], - ["menu", {"reserved": false}], - ["menuitem", {"reserved": false}], - ["meta", {"reserved": true}], - ["meter", {"reserved": false}], - ["nav", {"reserved": false}], - ["noembed", {"reserved": true}], - ["noscript", {"reserved": true}], - ["object", {"reserved": false}], - ["ol", {"reserved": false}], - ["optgroup", {"reserved": false}], - ["option", {"reserved": false}], - ["output", {"reserved": false}], - ["p", {"reserved": false}], - ["param", {"reserved": true}], - ["picture", {"reserved": true}], - ["pre", {"reserved": false}], - ["progress", {"reserved": false}], - ["q", {"reserved": false}], - ["rp", {"reserved": false}], - ["rt", {"reserved": false}], - ["rtc", {"reserved": false}], - ["ruby", {"reserved": false}], - ["s", {"reserved": false}], - ["samp", {"reserved": false}], - ["script", {"reserved": true}], - ["section", {"reserved": false}], - ["select", {"reserved": false}], - ["small", {"reserved": false}], - ["source", {"reserved": true}], - ["spacer", {"reserved": false}], - ["span", {"reserved": false}], - ["strike", {"reserved": false}], - ["strong", {"reserved": false}], - ["style", {"reserved": true}], - ["sub", {"reserved": false}], - ["summary", {"reserved": false}], - ["sup", {"reserved": false}], - ["table", {"reserved": false}], - ["tbody", {"reserved": false}], - ["td", {"reserved": false}], - ["textarea", {"reserved": false}], - ["tfoot", {"reserved": false}], - ["th", {"reserved": false}], - ["thead", {"reserved": false}], - ["time", {"reserved": false}], - ["title", {"reserved": true}], - ["tr", {"reserved": false}], - ["track", {"reserved": true}], - ["tt", {"reserved": false}], - ["u", {"reserved": false}], - ["ul", {"reserved": false}], - ["var", {"reserved": false}], - ["video", {"reserved": false}], - ["wbr", {"reserved": false}], - ["xmp", {"reserved": false}], - ], - ), - ); + describe('entries()', function () { + test.each(domMap.entries())(`Testing role: '%s' with defintion %o`, (role, definition) => { + expect(entriesList).toEqual( + expect.arrayContaining([[role, definition]]), + ); + }); + test.each([...domMap.entries()])(`Testing role: '%s'`, (role, definition) => { + expect(entriesList).toEqual( + expect.arrayContaining([[role, definition]]), + ); + }); }); - it('forEach', function () { + describe('forEach()', function () { const output = []; let context; domMap.forEach((value, key, map) => { @@ -283,828 +155,50 @@ describe('domMap API', function () { context = map; } }); - expect(output).toEqual( - expect.arrayContaining( - [ - ["a", {"reserved": false}], - ["abbr", {"reserved": false}], - ["acronym", {"reserved": false}], - ["address", {"reserved": false}], - ["applet", {"reserved": false}], - ["area", {"reserved": false}], - ["article", {"reserved": false}], - ["aside", {"reserved": false}], - ["audio", {"reserved": false}], - ["b", {"reserved": false}], - ["base", {"reserved": true}], - ["bdi", {"reserved": false}], - ["bdo", {"reserved": false}], - ["big", {"reserved": false}], - ["blink", {"reserved": false}], - ["blockquote", {"reserved": false}], - ["body", {"reserved": false}], - ["br", {"reserved": false}], - ["button", {"reserved": false}], - ["canvas", {"reserved": false}], - ["caption", {"reserved": false}], - ["center", {"reserved": false}], - ["cite", {"reserved": false}], - ["code", {"reserved": false}], - ["col", {"reserved": true}], - ["colgroup", {"reserved": true}], - ["content", {"reserved": false}], - ["data", {"reserved": false}], - ["datalist", {"reserved": false}], - ["dd", {"reserved": false}], - ["del", {"reserved": false}], - ["details", {"reserved": false}], - ["dfn", {"reserved": false}], - ["dialog", {"reserved": false}], - ["dir", {"reserved": false}], - ["div", {"reserved": false}], - ["dl", {"reserved": false}], - ["dt", {"reserved": false}], - ["em", {"reserved": false}], - ["embed", {"reserved": false}], - ["fieldset", {"reserved": false}], - ["figcaption", {"reserved": false}], - ["figure", {"reserved": false}], - ["font", {"reserved": false}], - ["footer", {"reserved": false}], - ["form", {"reserved": false}], - ["frame", {"reserved": false}], - ["frameset", {"reserved": false}], - ["h1", {"reserved": false}], - ["h2", {"reserved": false}], - ["h3", {"reserved": false}], - ["h4", {"reserved": false}], - ["h5", {"reserved": false}], - ["h6", {"reserved": false}], - ["head", {"reserved": true}], - ["header", {"reserved": false}], - ["hgroup", {"reserved": false}], - ["hr", {"reserved": false}], - ["html", {"reserved": true}], - ["i", {"reserved": false}], - ["iframe", {"reserved": false}], - ["img", {"reserved": false}], - ["input", {"reserved": false}], - ["ins", {"reserved": false}], - ["kbd", {"reserved": false}], - ["keygen", {"reserved": false}], - ["label", {"reserved": false}], - ["legend", {"reserved": false}], - ["li", {"reserved": false}], - ["link", {"reserved": true}], - ["main", {"reserved": false}], - ["map", {"reserved": false}], - ["mark", {"reserved": false}], - ["marquee", {"reserved": false}], - ["menu", {"reserved": false}], - ["menuitem", {"reserved": false}], - ["meta", {"reserved": true}], - ["meter", {"reserved": false}], - ["nav", {"reserved": false}], - ["noembed", {"reserved": true}], - ["noscript", {"reserved": true}], - ["object", {"reserved": false}], - ["ol", {"reserved": false}], - ["optgroup", {"reserved": false}], - ["option", {"reserved": false}], - ["output", {"reserved": false}], - ["p", {"reserved": false}], - ["param", {"reserved": true}], - ["picture", {"reserved": true}], - ["pre", {"reserved": false}], - ["progress", {"reserved": false}], - ["q", {"reserved": false}], - ["rp", {"reserved": false}], - ["rt", {"reserved": false}], - ["rtc", {"reserved": false}], - ["ruby", {"reserved": false}], - ["s", {"reserved": false}], - ["samp", {"reserved": false}], - ["script", {"reserved": true}], - ["section", {"reserved": false}], - ["select", {"reserved": false}], - ["small", {"reserved": false}], - ["source", {"reserved": true}], - ["spacer", {"reserved": false}], - ["span", {"reserved": false}], - ["strike", {"reserved": false}], - ["strong", {"reserved": false}], - ["style", {"reserved": true}], - ["sub", {"reserved": false}], - ["summary", {"reserved": false}], - ["sup", {"reserved": false}], - ["table", {"reserved": false}], - ["tbody", {"reserved": false}], - ["td", {"reserved": false}], - ["textarea", {"reserved": false}], - ["tfoot", {"reserved": false}], - ["th", {"reserved": false}], - ["thead", {"reserved": false}], - ["time", {"reserved": false}], - ["title", {"reserved": true}], - ["tr", {"reserved": false}], - ["track", {"reserved": true}], - ["tt", {"reserved": false}], - ["u", {"reserved": false}], - ["ul", {"reserved": false}], - ["var", {"reserved": false}], - ["video", {"reserved": false}], - ["wbr", {"reserved": false}], - ["xmp", {"reserved": false}], - ] - ) - ); - expect(context).toEqual( - expect.arrayContaining( - [ - ["a", {"reserved": false}], - ["abbr", {"reserved": false}], - ["acronym", {"reserved": false}], - ["address", {"reserved": false}], - ["applet", {"reserved": false}], - ["area", {"reserved": false}], - ["article", {"reserved": false}], - ["aside", {"reserved": false}], - ["audio", {"reserved": false}], - ["b", {"reserved": false}], - ["base", {"reserved": true}], - ["bdi", {"reserved": false}], - ["bdo", {"reserved": false}], - ["big", {"reserved": false}], - ["blink", {"reserved": false}], - ["blockquote", {"reserved": false}], - ["body", {"reserved": false}], - ["br", {"reserved": false}], - ["button", {"reserved": false}], - ["canvas", {"reserved": false}], - ["caption", {"reserved": false}], - ["center", {"reserved": false}], - ["cite", {"reserved": false}], - ["code", {"reserved": false}], - ["col", {"reserved": true}], - ["colgroup", {"reserved": true}], - ["content", {"reserved": false}], - ["data", {"reserved": false}], - ["datalist", {"reserved": false}], - ["dd", {"reserved": false}], - ["del", {"reserved": false}], - ["details", {"reserved": false}], - ["dfn", {"reserved": false}], - ["dialog", {"reserved": false}], - ["dir", {"reserved": false}], - ["div", {"reserved": false}], - ["dl", {"reserved": false}], - ["dt", {"reserved": false}], - ["em", {"reserved": false}], - ["embed", {"reserved": false}], - ["fieldset", {"reserved": false}], - ["figcaption", {"reserved": false}], - ["figure", {"reserved": false}], - ["font", {"reserved": false}], - ["footer", {"reserved": false}], - ["form", {"reserved": false}], - ["frame", {"reserved": false}], - ["frameset", {"reserved": false}], - ["h1", {"reserved": false}], - ["h2", {"reserved": false}], - ["h3", {"reserved": false}], - ["h4", {"reserved": false}], - ["h5", {"reserved": false}], - ["h6", {"reserved": false}], - ["head", {"reserved": true}], - ["header", {"reserved": false}], - ["hgroup", {"reserved": false}], - ["hr", {"reserved": false}], - ["html", {"reserved": true}], - ["i", {"reserved": false}], - ["iframe", {"reserved": false}], - ["img", {"reserved": false}], - ["input", {"reserved": false}], - ["ins", {"reserved": false}], - ["kbd", {"reserved": false}], - ["keygen", {"reserved": false}], - ["label", {"reserved": false}], - ["legend", {"reserved": false}], - ["li", {"reserved": false}], - ["link", {"reserved": true}], - ["main", {"reserved": false}], - ["map", {"reserved": false}], - ["mark", {"reserved": false}], - ["marquee", {"reserved": false}], - ["menu", {"reserved": false}], - ["menuitem", {"reserved": false}], - ["meta", {"reserved": true}], - ["meter", {"reserved": false}], - ["nav", {"reserved": false}], - ["noembed", {"reserved": true}], - ["noscript", {"reserved": true}], - ["object", {"reserved": false}], - ["ol", {"reserved": false}], - ["optgroup", {"reserved": false}], - ["option", {"reserved": false}], - ["output", {"reserved": false}], - ["p", {"reserved": false}], - ["param", {"reserved": true}], - ["picture", {"reserved": true}], - ["pre", {"reserved": false}], - ["progress", {"reserved": false}], - ["q", {"reserved": false}], - ["rp", {"reserved": false}], - ["rt", {"reserved": false}], - ["rtc", {"reserved": false}], - ["ruby", {"reserved": false}], - ["s", {"reserved": false}], - ["samp", {"reserved": false}], - ["script", {"reserved": true}], - ["section", {"reserved": false}], - ["select", {"reserved": false}], - ["small", {"reserved": false}], - ["source", {"reserved": true}], - ["spacer", {"reserved": false}], - ["span", {"reserved": false}], - ["strike", {"reserved": false}], - ["strong", {"reserved": false}], - ["style", {"reserved": true}], - ["sub", {"reserved": false}], - ["summary", {"reserved": false}], - ["sup", {"reserved": false}], - ["table", {"reserved": false}], - ["tbody", {"reserved": false}], - ["td", {"reserved": false}], - ["textarea", {"reserved": false}], - ["tfoot", {"reserved": false}], - ["th", {"reserved": false}], - ["thead", {"reserved": false}], - ["time", {"reserved": false}], - ["title", {"reserved": true}], - ["tr", {"reserved": false}], - ["track", {"reserved": true}], - ["tt", {"reserved": false}], - ["u", {"reserved": false}], - ["ul", {"reserved": false}], - ["var", {"reserved": false}], - ["video", {"reserved": false}], - ["wbr", {"reserved": false}], - ["xmp", {"reserved": false}], - ] - ) - ); + test.each(output)(`Testing role: '%s'`, (role, definition) => { + expect(entriesList).toEqual( + expect.arrayContaining([[role, definition]]), + ); + }); + test.each(context)(`Testing role: '%s'`, (role, definition) => { + expect(entriesList).toEqual( + expect.arrayContaining([[role, definition]]), + ); + }); }); - it('get', function () { + it('get()', function () { expect(domMap.get('a')).toBeDefined(); expect(domMap.get('fake element')).toBeUndefined(); }); - it('has', function () { + it('has()', function () { expect(domMap.has('a')).toEqual(true); expect(domMap.has('fake element')).toEqual(false); }); - it('keys', function () { - expect(domMap.keys()).toEqual( - expect.arrayContaining( - [ - "a", - "abbr", - "acronym", - "address", - "applet", - "area", - "article", - "aside", - "audio", - "b", - "base", - "bdi", - "bdo", - "big", - "blink", - "blockquote", - "body", - "br", - "button", - "canvas", - "caption", - "center", - "cite", - "code", - "col", - "colgroup", - "content", - "data", - "datalist", - "dd", - "del", - "details", - "dfn", - "dialog", - "dir", - "div", - "dl", - "dt", - "em", - "embed", - "fieldset", - "figcaption", - "figure", - "font", - "footer", - "form", - "frame", - "frameset", - "h1", - "h2", - "h3", - "h4", - "h5", - "h6", - "head", - "header", - "hgroup", - "hr", - "html", - "i", - "iframe", - "img", - "input", - "ins", - "kbd", - "keygen", - "label", - "legend", - "li", - "link", - "main", - "map", - "mark", - "marquee", - "menu", - "menuitem", - "meta", - "meter", - "nav", - "noembed", - "noscript", - "object", - "ol", - "optgroup", - "option", - "output", - "p", - "param", - "picture", - "pre", - "progress", - "q", - "rp", - "rt", - "rtc", - "ruby", - "s", - "samp", - "script", - "section", - "select", - "small", - "source", - "spacer", - "span", - "strike", - "strong", - "style", - "sub", - "summary", - "sup", - "table", - "tbody", - "td", - "textarea", - "tfoot", - "th", - "thead", - "time", - "title", - "tr", - "track", - "tt", - "u", - "ul", - "var", - "video", - "wbr", - "xmp", - ], - ), - ); - expect([...domMap.keys()]).toEqual( - expect.arrayContaining( - [ - "a", - "abbr", - "acronym", - "address", - "applet", - "area", - "article", - "aside", - "audio", - "b", - "base", - "bdi", - "bdo", - "big", - "blink", - "blockquote", - "body", - "br", - "button", - "canvas", - "caption", - "center", - "cite", - "code", - "col", - "colgroup", - "content", - "data", - "datalist", - "dd", - "del", - "details", - "dfn", - "dialog", - "dir", - "div", - "dl", - "dt", - "em", - "embed", - "fieldset", - "figcaption", - "figure", - "font", - "footer", - "form", - "frame", - "frameset", - "h1", - "h2", - "h3", - "h4", - "h5", - "h6", - "head", - "header", - "hgroup", - "hr", - "html", - "i", - "iframe", - "img", - "input", - "ins", - "kbd", - "keygen", - "label", - "legend", - "li", - "link", - "main", - "map", - "mark", - "marquee", - "menu", - "menuitem", - "meta", - "meter", - "nav", - "noembed", - "noscript", - "object", - "ol", - "optgroup", - "option", - "output", - "p", - "param", - "picture", - "pre", - "progress", - "q", - "rp", - "rt", - "rtc", - "ruby", - "s", - "samp", - "script", - "section", - "select", - "small", - "source", - "spacer", - "span", - "strike", - "strong", - "style", - "sub", - "summary", - "sup", - "table", - "tbody", - "td", - "textarea", - "tfoot", - "th", - "thead", - "time", - "title", - "tr", - "track", - "tt", - "u", - "ul", - "var", - "video", - "wbr", - "xmp", - ], - ), - ); + describe('keys()', function () { + const entriesKeys = entriesList.map(entry => entry[0]); + test.each(domMap.keys())('Testing key: %o', (key) => { + expect(entriesKeys).toEqual( + expect.arrayContaining([key]), + ); + }); + test.each([...domMap.keys()])('Testing key: %o', (key) => { + expect(entriesKeys).toEqual( + expect.arrayContaining([key]), + ); + }); }); - it('values', function () { - expect(domMap.values()).toEqual( - expect.arrayContaining( - [ - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - ], - ), - ); - expect([...domMap.values()]).toEqual( - expect.arrayContaining( - [ - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": true}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - {"reserved": false}, - ], - ), - ); + describe('values()', function () { + const entriesValues = entriesList.map(entry => entry[1]); + test.each(domMap.values().map(value => [value]))('Testing value: %o', (value) => { + expect(entriesValues).toEqual( + expect.arrayContaining([value]), + ); + }); + test.each([...domMap.values()].map(value => [value]))('Testing value: %o', (value) => { + expect(entriesValues).toEqual( + expect.arrayContaining([value]), + ); + }); }); }); @@ -1113,284 +207,26 @@ describe('domMap', function () { it('should have an iterator defined', function () { expect(domMap[Symbol.iterator]).not.toBeUndefined(); }); - it('should support the spread operator', function () { - expect([...domMap].length).toEqual(129); - expect([...domMap]).toEqual( - expect.arrayContaining( - [ - ["a", {"reserved": false}], - ["abbr", {"reserved": false}], - ["acronym", {"reserved": false}], - ["address", {"reserved": false}], - ["applet", {"reserved": false}], - ["area", {"reserved": false}], - ["article", {"reserved": false}], - ["aside", {"reserved": false}], - ["audio", {"reserved": false}], - ["b", {"reserved": false}], - ["base", {"reserved": true}], - ["bdi", {"reserved": false}], - ["bdo", {"reserved": false}], - ["big", {"reserved": false}], - ["blink", {"reserved": false}], - ["blockquote", {"reserved": false}], - ["body", {"reserved": false}], - ["br", {"reserved": false}], - ["button", {"reserved": false}], - ["canvas", {"reserved": false}], - ["caption", {"reserved": false}], - ["center", {"reserved": false}], - ["cite", {"reserved": false}], - ["code", {"reserved": false}], - ["col", {"reserved": true}], - ["colgroup", {"reserved": true}], - ["content", {"reserved": false}], - ["data", {"reserved": false}], - ["datalist", {"reserved": false}], - ["dd", {"reserved": false}], - ["del", {"reserved": false}], - ["details", {"reserved": false}], - ["dfn", {"reserved": false}], - ["dialog", {"reserved": false}], - ["dir", {"reserved": false}], - ["div", {"reserved": false}], - ["dl", {"reserved": false}], - ["dt", {"reserved": false}], - ["em", {"reserved": false}], - ["embed", {"reserved": false}], - ["fieldset", {"reserved": false}], - ["figcaption", {"reserved": false}], - ["figure", {"reserved": false}], - ["font", {"reserved": false}], - ["footer", {"reserved": false}], - ["form", {"reserved": false}], - ["frame", {"reserved": false}], - ["frameset", {"reserved": false}], - ["h1", {"reserved": false}], - ["h2", {"reserved": false}], - ["h3", {"reserved": false}], - ["h4", {"reserved": false}], - ["h5", {"reserved": false}], - ["h6", {"reserved": false}], - ["head", {"reserved": true}], - ["header", {"reserved": false}], - ["hgroup", {"reserved": false}], - ["hr", {"reserved": false}], - ["html", {"reserved": true}], - ["i", {"reserved": false}], - ["iframe", {"reserved": false}], - ["img", {"reserved": false}], - ["input", {"reserved": false}], - ["ins", {"reserved": false}], - ["kbd", {"reserved": false}], - ["keygen", {"reserved": false}], - ["label", {"reserved": false}], - ["legend", {"reserved": false}], - ["li", {"reserved": false}], - ["link", {"reserved": true}], - ["main", {"reserved": false}], - ["map", {"reserved": false}], - ["mark", {"reserved": false}], - ["marquee", {"reserved": false}], - ["menu", {"reserved": false}], - ["menuitem", {"reserved": false}], - ["meta", {"reserved": true}], - ["meter", {"reserved": false}], - ["nav", {"reserved": false}], - ["noembed", {"reserved": true}], - ["noscript", {"reserved": true}], - ["object", {"reserved": false}], - ["ol", {"reserved": false}], - ["optgroup", {"reserved": false}], - ["option", {"reserved": false}], - ["output", {"reserved": false}], - ["p", {"reserved": false}], - ["param", {"reserved": true}], - ["picture", {"reserved": true}], - ["pre", {"reserved": false}], - ["progress", {"reserved": false}], - ["q", {"reserved": false}], - ["rp", {"reserved": false}], - ["rt", {"reserved": false}], - ["rtc", {"reserved": false}], - ["ruby", {"reserved": false}], - ["s", {"reserved": false}], - ["samp", {"reserved": false}], - ["script", {"reserved": true}], - ["section", {"reserved": false}], - ["select", {"reserved": false}], - ["small", {"reserved": false}], - ["source", {"reserved": true}], - ["spacer", {"reserved": false}], - ["span", {"reserved": false}], - ["strike", {"reserved": false}], - ["strong", {"reserved": false}], - ["style", {"reserved": true}], - ["sub", {"reserved": false}], - ["summary", {"reserved": false}], - ["sup", {"reserved": false}], - ["table", {"reserved": false}], - ["tbody", {"reserved": false}], - ["td", {"reserved": false}], - ["textarea", {"reserved": false}], - ["tfoot", {"reserved": false}], - ["th", {"reserved": false}], - ["thead", {"reserved": false}], - ["time", {"reserved": false}], - ["title", {"reserved": true}], - ["tr", {"reserved": false}], - ["track", {"reserved": true}], - ["tt", {"reserved": false}], - ["u", {"reserved": false}], - ["ul", {"reserved": false}], - ["var", {"reserved": false}], - ["video", {"reserved": false}], - ["wbr", {"reserved": false}], - ["xmp", {"reserved": false}], - ] - ) - ); + describe('spread operator', function () { + it('should have a specific length', function () { + expect([...domMap].length).toEqual(129); + }); + test.each([...domMap])('Testing element: %o', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); - it('should support the for..of pattern', function () { + describe('for..of pattern', function () { const output = []; for (const [key, value] of domMap) { output.push([key, value]); } - expect(output).toEqual( - expect.arrayContaining( - [ - ["a", {"reserved": false}], - ["abbr", {"reserved": false}], - ["acronym", {"reserved": false}], - ["address", {"reserved": false}], - ["applet", {"reserved": false}], - ["area", {"reserved": false}], - ["article", {"reserved": false}], - ["aside", {"reserved": false}], - ["audio", {"reserved": false}], - ["b", {"reserved": false}], - ["base", {"reserved": true}], - ["bdi", {"reserved": false}], - ["bdo", {"reserved": false}], - ["big", {"reserved": false}], - ["blink", {"reserved": false}], - ["blockquote", {"reserved": false}], - ["body", {"reserved": false}], - ["br", {"reserved": false}], - ["button", {"reserved": false}], - ["canvas", {"reserved": false}], - ["caption", {"reserved": false}], - ["center", {"reserved": false}], - ["cite", {"reserved": false}], - ["code", {"reserved": false}], - ["col", {"reserved": true}], - ["colgroup", {"reserved": true}], - ["content", {"reserved": false}], - ["data", {"reserved": false}], - ["datalist", {"reserved": false}], - ["dd", {"reserved": false}], - ["del", {"reserved": false}], - ["details", {"reserved": false}], - ["dfn", {"reserved": false}], - ["dialog", {"reserved": false}], - ["dir", {"reserved": false}], - ["div", {"reserved": false}], - ["dl", {"reserved": false}], - ["dt", {"reserved": false}], - ["em", {"reserved": false}], - ["embed", {"reserved": false}], - ["fieldset", {"reserved": false}], - ["figcaption", {"reserved": false}], - ["figure", {"reserved": false}], - ["font", {"reserved": false}], - ["footer", {"reserved": false}], - ["form", {"reserved": false}], - ["frame", {"reserved": false}], - ["frameset", {"reserved": false}], - ["h1", {"reserved": false}], - ["h2", {"reserved": false}], - ["h3", {"reserved": false}], - ["h4", {"reserved": false}], - ["h5", {"reserved": false}], - ["h6", {"reserved": false}], - ["head", {"reserved": true}], - ["header", {"reserved": false}], - ["hgroup", {"reserved": false}], - ["hr", {"reserved": false}], - ["html", {"reserved": true}], - ["i", {"reserved": false}], - ["iframe", {"reserved": false}], - ["img", {"reserved": false}], - ["input", {"reserved": false}], - ["ins", {"reserved": false}], - ["kbd", {"reserved": false}], - ["keygen", {"reserved": false}], - ["label", {"reserved": false}], - ["legend", {"reserved": false}], - ["li", {"reserved": false}], - ["link", {"reserved": true}], - ["main", {"reserved": false}], - ["map", {"reserved": false}], - ["mark", {"reserved": false}], - ["marquee", {"reserved": false}], - ["menu", {"reserved": false}], - ["menuitem", {"reserved": false}], - ["meta", {"reserved": true}], - ["meter", {"reserved": false}], - ["nav", {"reserved": false}], - ["noembed", {"reserved": true}], - ["noscript", {"reserved": true}], - ["object", {"reserved": false}], - ["ol", {"reserved": false}], - ["optgroup", {"reserved": false}], - ["option", {"reserved": false}], - ["output", {"reserved": false}], - ["p", {"reserved": false}], - ["param", {"reserved": true}], - ["picture", {"reserved": true}], - ["pre", {"reserved": false}], - ["progress", {"reserved": false}], - ["q", {"reserved": false}], - ["rp", {"reserved": false}], - ["rt", {"reserved": false}], - ["rtc", {"reserved": false}], - ["ruby", {"reserved": false}], - ["s", {"reserved": false}], - ["samp", {"reserved": false}], - ["script", {"reserved": true}], - ["section", {"reserved": false}], - ["select", {"reserved": false}], - ["small", {"reserved": false}], - ["source", {"reserved": true}], - ["spacer", {"reserved": false}], - ["span", {"reserved": false}], - ["strike", {"reserved": false}], - ["strong", {"reserved": false}], - ["style", {"reserved": true}], - ["sub", {"reserved": false}], - ["summary", {"reserved": false}], - ["sup", {"reserved": false}], - ["table", {"reserved": false}], - ["tbody", {"reserved": false}], - ["td", {"reserved": false}], - ["textarea", {"reserved": false}], - ["tfoot", {"reserved": false}], - ["th", {"reserved": false}], - ["thead", {"reserved": false}], - ["time", {"reserved": false}], - ["title", {"reserved": true}], - ["tr", {"reserved": false}], - ["track", {"reserved": true}], - ["tt", {"reserved": false}], - ["u", {"reserved": false}], - ["ul", {"reserved": false}], - ["var", {"reserved": false}], - ["video", {"reserved": false}], - ["wbr", {"reserved": false}], - ["xmp", {"reserved": false}], - ] - ) - ); + test.each(output)('Testing element: %o', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); }); }); diff --git a/__tests__/src/elementRoleMap-test.js b/__tests__/src/elementRoleMap-test.js index e930b9ff..972a0063 100644 --- a/__tests__/src/elementRoleMap-test.js +++ b/__tests__/src/elementRoleMap-test.js @@ -1,196 +1,140 @@ import expect from 'expect'; import elementRoleMap from '../../src/elementRoleMap'; +const entriesList = [ + [{"name": "article"}, ["article"]], + [{"constraints": ["scoped to the body element"], "name": "header"}, ["banner"]], + [{"name": "blockquote"}, ["blockquote"]], + [{"attributes": [{"name": "type", "value": "button"}], "name": "input"}, ["button"]], + [{"attributes": [{"name": "type", "value": "image"}], "name": "input"}, ["button"]], + [{"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, ["button"]], + [{"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, ["button"]], + [{"name": "button"}, ["button"]], + [{"name": "caption"}, ["caption"]], + [{"constraints": ["ancestor table element has table role"], "name": "td"}, ["cell"]], + [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}, ["checkbox"]], + [{"name": "code"}, ["code"]], + [{"name": "th"}, ["columnheader"]], + [{"attributes": [{"name": "scope", "value": "col"}], "name": "th"}, ["columnheader"]], + [{"attributes": [{"name": "scope", "value": "colgroup"}], "name": "th"}, ["columnheader"]], + [{"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "email"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, ["combobox"]], + [{"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "search"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, ["combobox"]], + [{"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "tel"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, ["combobox"]], + [{"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "text"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, ["combobox"]], + [{"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "url"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, ["combobox"]], + [{"attributes": [{"name": "multiple"}, {"name": "size"}], "constraints": ["the multiple attribute and the size attribute do not have a value greater than 1"], "name": "select"}, ["combobox"]], + [{"name": "aside"}, ["complementary"]], + [{"attributes": [{"name": "aria-label"}], "constraints": ["scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "aside"}, ["complementary"]], + [{"attributes": [{"name": "aria-labelledby"}], "constraints": ["scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "aside"}, ["complementary"]], + [{"constraints": ["scoped to the body element"], "name": "footer"}, ["contentinfo"]], + [{"name": "dd"}, ["definition"]], + [{"name": "del"}, ["deletion"]], + [{"name": "dialog"}, ["dialog"]], + [{"name": "em"}, ["emphasis"]], + [{"name": "html"}, ["document"]], + [{"name": "figure"}, ["figure"]], + [{"attributes": [{"name": "aria-label"}], "name": "form"}, ["form"]], + [{"attributes": [{"name": "aria-labelledby"}], "name": "form"}, ["form"]], + [{"attributes": [{"name": "name"}], "name": "form"}, ["form"]], + [{"name": "a"}, ["generic"]], + [{"name": "area"}, ["generic"]], + [{"name": "aside"}, ["generic"]], + [{"name": "b"}, ["generic"]], + [{"name": "bdo"}, ["generic"]], + [{"name": "body"}, ["generic"]], + [{"name": "data"}, ["generic"]], + [{"name": "div"}, ["generic"]], + [{"constraints": ["scoped to the main element", "scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "footer"}, ["generic"]], + [{"constraints": ["scoped to the main element", "scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "header"}, ["generic"]], + [{"name": "hgroup"}, ["generic"]], + [{"name": "i"}, ["generic"]], + [{"name": "pre"}, ["generic"]], + [{"name": "q"}, ["generic"]], + [{"name": "samp"}, ["generic"]], + [{"name": "section"}, ["generic"]], + [{"name": "small"}, ["generic"]], + [{"name": "span"}, ["generic"]], + [{"name": "u"}, ["generic"]], + [{"constraints": ["ancestor table element has grid role"], "name": "td"}, ["gridcell"]], + [{"name": "details"}, ["group"]], + [{"name": "fieldset"}, ["group"]], + [{"name": "optgroup"}, ["group"]], + [{"name": "address"}, ["group"]], + [{"name": "h1"}, ["heading"]], + [{"name": "h2"}, ["heading"]], + [{"name": "h3"}, ["heading"]], + [{"name": "h4"}, ["heading"]], + [{"name": "h5"}, ["heading"]], + [{"name": "h6"}, ["heading"]], + [{"name": "img"}, ["img"]], + [{"name": "ins"}, ["insertion"]], + [{"attributes": [{"name": "href"}], "name": "a"}, ["link"]], + [{"attributes": [{"name": "href"}], "name": "area"}, ["link"]], + [{"name": "menu"}, ["list"]], + [{"name": "ol"}, ["list"]], + [{"name": "ul"}, ["list"]], + [{"attributes": [{"name": "size"}, {"name": "multiple"}], "constraints": ["the size attribute value is greater than 1"], "name": "select"}, ["listbox"]], + [{"attributes": [{"name": "size"}], "constraints": ["the size attribute value is greater than 1"], "name": "select"}, ["listbox"]], + [{"attributes": [{"name": "multiple"}], "constraints": ["the multiple attribute value is greater than 1"], "name": "select"}, ["listbox"]], + [{"attributes": [{"name": "aria-multiselectable", "value": "true"}], "constraints": ["the datalist selection model allows multiple option elements to be selected at a time"], "name": "datalist"}, ["listbox"]], + [{"attributes": [{"name": "aria-multiselectable", "value": "false"}], "name": "datalist"}, ["listbox"]], + [{"constraints": ["direct descendant of ol", "direct descendant of ul", "direct descendant of menu"], "name": "li"}, ["listitem"]], + [{"name": "main"}, ["main"]], + [{"name": "mark"}, ["mark"]], + [{"name": "math"}, ["math"]], + [{"name": "meter"}, ["meter"]], + [{"name": "nav"}, ["navigation"]], + [{"name": "option"}, ["option"]], + [{"name": "p"}, ["paragraph"]], + [{"attributes": [{"name": "alt", "value": ""}], "name": "img"}, ["presentation"]], + [{"name": "progress"}, ["progressbar"]], + [{"attributes": [{"name": "aria-valuemax"}, {"name": "aria-valuemin", "value": 0}, {"name": "aria-valuenow"}], "constraints": ["the progress bar is determinate"],"name": "progress"}, ["progressbar"]], + [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}, ["radio"]], + [{"attributes": [{"name": "aria-label"}], "name": "section"}, ["region"]], + [{"attributes": [{"name": "aria-labelledby"}], "name": "section"}, ["region"]], + [{"name": "tr"}, ["row"]], + [{"name": "tbody"}, ["rowgroup"]], + [{"name": "tfoot"}, ["rowgroup"]], + [{"name": "thead"}, ["rowgroup"]], + [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, ["rowheader"]], + [{"attributes": [{"name": "scope", "value": "rowgroup"}], "name": "th"}, ["rowheader"]], + [{"attributes": [{"name": "list"}, {"name": "type", "value": "search"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["searchbox"]], + [{"attributes": [{"name": "aria-label"}], "name": "section"}, ["section"]], + [{"attributes": [{"name": "aria-labelledby"}], "name": "section"}, ["section"]], + [{"name": "hr"}, ["separator"]], + [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}, ["slider"]], + [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}, ["spinbutton"]], + [{"name": "output"}, ["status"]], + [{"name": "strong"}, ["strong"]], + [{"name": "sub"}, ["subscript"]], + [{"name": "sup"}, ["superscript"]], + [{"attributes": [{"name": "aria-checked"}], "name": "button"}, ["switch"]], + [{"name": "table"}, ["table"]], + [{"name": "dfn"}, ["term"]], + [{"name": "dt"}, ["term"]], + [{"constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]], + [{"attributes": [{"name": "type", "value": "email"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]], + [{"attributes": [{"name": "type", "value": "tel"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]], + [{"attributes": [{"name": "type", "value": "text"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]], + [{"attributes": [{"name": "type", "value": "url"}], "constraints": ["the list attribute is not set"], "name": "input"}, ["textbox"]], + [{"name": "textarea"}, ["textbox"]], + [{"name": "time"}, ["time"]], +]; + describe('elementRoleMap API', function () { - it('entries', function () { - expect(elementRoleMap.entries()).toEqual( - expect.arrayContaining( - [ - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "rel"}, ["roletype"]], - [{"name": "article"}, ["article"]], - [{"constraints": ["direct descendant of document"], "name": "header"}, ["banner"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "type", "value": "button"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "image"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, ["button"]], - [{"name": "button"}, ["button"]], - [{"constraints": ["descendant of table"], "name": "td"}, ["cell"]], - [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}, ["checkbox"]], - [{"name": "th"}, ["columnheader"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}, ["combobox"]], - [{"name": "aside"}, ["complementary"]], - [{"constraints": ["direct descendant of document"], "name": "footer"}, ["contentinfo"]], - [{"name": "dd"}, ["definition"]], - [{"name": "dialog"}, ["dialog"]], - [{"name": "body"}, ["document"]], - [{"name": "figure"}, ["figure"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}, ["form"]], - [{"name": "span"}, ["generic"]], - [{"name": "div"}, ["generic"]], - [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}, ["grid"]], - [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}, ["gridcell"]], - [{"name": "details"}, ["group"]], - [{"name": "fieldset"}, ["group"]], - [{"name": "optgroup"}, ["group"]], - [{"name": "h1"}, ["heading"]], - [{"name": "h2"}, ["heading"]], - [{"name": "h3"}, ["heading"]], - [{"name": "h4"}, ["heading"]], - [{"name": "h5"}, ["heading"]], - [{"name": "h6"}, ["heading"]], - [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"name": "href"}], "name": "a"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "area"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "link"}, ["link"]], - [{"name": "menu"}, ["list"]], - [{"name": "ol"}, ["list"]], - [{"name": "ul"}, ["list"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"name": "datalist"}, ["listbox"]], - [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}, ["listitem"]], - [{"name": "main"}, ["main"]], - [{"name": "math"}, ["math"]], - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "nav"}, ["navigation"]], - [{"name": "option"}, ["option"]], - [{"name": "progress"}, ["progressbar"]], - [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}, ["radio"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, ["region"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, ["region"]], - [{"name": "frame"}, ["region"]], - [{"name": "tr"}, ["row"]], - [{"name": "tbody"}, ["rowgroup"]], - [{"name": "tfoot"}, ["rowgroup"]], - [{"name": "thead"}, ["rowgroup"]], - [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, ["rowheader"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["searchbox"]], - [{"name": "hr"}, ["separator"]], - [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}, ["slider"]], - [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}, ["spinbutton"]], - [{"name": "output"}, ["status"]], - [{"name": "table"}, ["table"]], - [{"name": "dfn"}, ["term"]], - [{"name": "dt"}, ["term"]], - [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["textbox"]], - [{"name": "textarea"}, ["textbox"]] - ] - ) - ); - expect([...elementRoleMap.entries()]).toEqual( - expect.arrayContaining( - [ - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "rel"}, ["roletype"]], - [{"name": "article"}, ["article"]], - [{"constraints": ["direct descendant of document"], "name": "header"}, ["banner"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "type", "value": "button"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "image"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, ["button"]], - [{"name": "button"}, ["button"]], - [{"constraints": ["descendant of table"], "name": "td"}, ["cell"]], - [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}, ["checkbox"]], - [{"name": "th"}, ["columnheader"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}, ["combobox"]], - [{"name": "aside"}, ["complementary"]], - [{"constraints": ["direct descendant of document"], "name": "footer"}, ["contentinfo"]], - [{"name": "dd"}, ["definition"]], - [{"name": "dialog"}, ["dialog"]], - [{"name": "body"}, ["document"]], - [{"name": "figure"}, ["figure"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}, ["form"]], - [{"name": "span"}, ["generic"]], - [{"name": "div"}, ["generic"]], - [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}, ["grid"]], - [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}, ["gridcell"]], - [{"name": "details"}, ["group"]], - [{"name": "fieldset"}, ["group"]], - [{"name": "optgroup"}, ["group"]], - [{"name": "h1"}, ["heading"]], - [{"name": "h2"}, ["heading"]], - [{"name": "h3"}, ["heading"]], - [{"name": "h4"}, ["heading"]], - [{"name": "h5"}, ["heading"]], - [{"name": "h6"}, ["heading"]], - [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"name": "href"}], "name": "a"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "area"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "link"}, ["link"]], - [{"name": "menu"}, ["list"]], - [{"name": "ol"}, ["list"]], - [{"name": "ul"}, ["list"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"name": "datalist"}, ["listbox"]], - [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}, ["listitem"]], - [{"name": "main"}, ["main"]], - [{"name": "math"}, ["math"]], - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "nav"}, ["navigation"]], - [{"name": "option"}, ["option"]], - [{"name": "progress"}, ["progressbar"]], - [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}, ["radio"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, ["region"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, ["region"]], - [{"name": "frame"}, ["region"]], - [{"name": "tr"}, ["row"]], - [{"name": "tbody"}, ["rowgroup"]], - [{"name": "tfoot"}, ["rowgroup"]], - [{"name": "thead"}, ["rowgroup"]], - [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, ["rowheader"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["searchbox"]], - [{"name": "hr"}, ["separator"]], - [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}, ["slider"]], - [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}, ["spinbutton"]], - [{"name": "output"}, ["status"]], - [{"name": "table"}, ["table"]], - [{"name": "dfn"}, ["term"]], - [{"name": "dt"}, ["term"]], - [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["textbox"]], - [{"name": "textarea"}, ["textbox"]] - ] - ) - ); + describe('entries()', function () { + test.each(elementRoleMap.entries())('Testing element: %o', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); + test.each([...elementRoleMap.entries()])('Testing element: %o', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); - it('forEach', function () { + describe('forEach()', function () { const output = []; let context; elementRoleMap.forEach((value, key, map) => { @@ -199,194 +143,18 @@ describe('elementRoleMap API', function () { context = map; } }); - expect(output).toEqual( - expect.arrayContaining( - [ - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "rel"}, ["roletype"]], - [{"name": "article"}, ["article"]], - [{"constraints": ["direct descendant of document"], "name": "header"}, ["banner"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "type", "value": "button"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "image"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, ["button"]], - [{"name": "button"}, ["button"]], - [{"constraints": ["descendant of table"], "name": "td"}, ["cell"]], - [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}, ["checkbox"]], - [{"name": "th"}, ["columnheader"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}, ["combobox"]], - [{"name": "aside"}, ["complementary"]], - [{"constraints": ["direct descendant of document"], "name": "footer"}, ["contentinfo"]], - [{"name": "dd"}, ["definition"]], - [{"name": "dialog"}, ["dialog"]], - [{"name": "body"}, ["document"]], - [{"name": "figure"}, ["figure"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}, ["form"]], - [{"name": "span"}, ["generic"]], - [{"name": "div"}, ["generic"]], - [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}, ["grid"]], - [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}, ["gridcell"]], - [{"name": "details"}, ["group"]], - [{"name": "fieldset"}, ["group"]], - [{"name": "optgroup"}, ["group"]], - [{"name": "h1"}, ["heading"]], - [{"name": "h2"}, ["heading"]], - [{"name": "h3"}, ["heading"]], - [{"name": "h4"}, ["heading"]], - [{"name": "h5"}, ["heading"]], - [{"name": "h6"}, ["heading"]], - [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"name": "href"}], "name": "a"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "area"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "link"}, ["link"]], - [{"name": "menu"}, ["list"]], - [{"name": "ol"}, ["list"]], - [{"name": "ul"}, ["list"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"name": "datalist"}, ["listbox"]], - [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}, ["listitem"]], - [{"name": "main"}, ["main"]], - [{"name": "math"}, ["math"]], - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "nav"}, ["navigation"]], - [{"name": "option"}, ["option"]], - [{"name": "progress"}, ["progressbar"]], - [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}, ["radio"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, ["region"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, ["region"]], - [{"name": "frame"}, ["region"]], - [{"name": "tr"}, ["row"]], - [{"name": "tbody"}, ["rowgroup"]], - [{"name": "tfoot"}, ["rowgroup"]], - [{"name": "thead"}, ["rowgroup"]], - [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, ["rowheader"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["searchbox"]], - [{"name": "hr"}, ["separator"]], - [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}, ["slider"]], - [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}, ["spinbutton"]], - [{"name": "output"}, ["status"]], - [{"name": "table"}, ["table"]], - [{"name": "dfn"}, ["term"]], - [{"name": "dt"}, ["term"]], - [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["textbox"]], - [{"name": "textarea"}, ["textbox"]] - ] - ) - ); - expect(context).toEqual( - expect.arrayContaining( - [ - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "rel"}, ["roletype"]], - [{"name": "article"}, ["article"]], - [{"constraints": ["direct descendant of document"], "name": "header"}, ["banner"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "type", "value": "button"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "image"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, ["button"]], - [{"name": "button"}, ["button"]], - [{"constraints": ["descendant of table"], "name": "td"}, ["cell"]], - [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}, ["checkbox"]], - [{"name": "th"}, ["columnheader"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}, ["combobox"]], - [{"name": "aside"}, ["complementary"]], - [{"constraints": ["direct descendant of document"], "name": "footer"}, ["contentinfo"]], - [{"name": "dd"}, ["definition"]], - [{"name": "dialog"}, ["dialog"]], - [{"name": "body"}, ["document"]], - [{"name": "figure"}, ["figure"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}, ["form"]], - [{"name": "span"}, ["generic"]], - [{"name": "div"}, ["generic"]], - [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}, ["grid"]], - [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}, ["gridcell"]], - [{"name": "details"}, ["group"]], - [{"name": "fieldset"}, ["group"]], - [{"name": "optgroup"}, ["group"]], - [{"name": "h1"}, ["heading"]], - [{"name": "h2"}, ["heading"]], - [{"name": "h3"}, ["heading"]], - [{"name": "h4"}, ["heading"]], - [{"name": "h5"}, ["heading"]], - [{"name": "h6"}, ["heading"]], - [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"name": "href"}], "name": "a"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "area"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "link"}, ["link"]], - [{"name": "menu"}, ["list"]], - [{"name": "ol"}, ["list"]], - [{"name": "ul"}, ["list"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"name": "datalist"}, ["listbox"]], - [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}, ["listitem"]], - [{"name": "main"}, ["main"]], - [{"name": "math"}, ["math"]], - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "nav"}, ["navigation"]], - [{"name": "option"}, ["option"]], - [{"name": "progress"}, ["progressbar"]], - [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}, ["radio"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, ["region"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, ["region"]], - [{"name": "frame"}, ["region"]], - [{"name": "tr"}, ["row"]], - [{"name": "tbody"}, ["rowgroup"]], - [{"name": "tfoot"}, ["rowgroup"]], - [{"name": "thead"}, ["rowgroup"]], - [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, ["rowheader"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["searchbox"]], - [{"name": "hr"}, ["separator"]], - [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}, ["slider"]], - [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}, ["spinbutton"]], - [{"name": "output"}, ["status"]], - [{"name": "table"}, ["table"]], - [{"name": "dfn"}, ["term"]], - [{"name": "dt"}, ["term"]], - [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["textbox"]], - [{"name": "textarea"}, ["textbox"]] - ] - ) - ); + test.each(output)('Testing element: %o', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); + test.each(context)('Testing element: %o', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); - it('get', function () { + it('get()', function () { expect(elementRoleMap.get({ attributes: [ { name: 'href' } @@ -412,7 +180,7 @@ describe('elementRoleMap API', function () { name: 'fake element', })).toBeUndefined(); }); - it('has', function () { + it('has()', function () { expect(elementRoleMap.has({ attributes: [ { name: 'href' } @@ -426,381 +194,31 @@ describe('elementRoleMap API', function () { name: 'fake element', })).toEqual(false); }); - it('keys', function () { - expect(elementRoleMap.keys()).toEqual( - expect.arrayContaining( - [ - {"name": "menuitem"}, - {"name": "rel"}, - {"name": "article"}, - {"constraints": ["direct descendant of document"], "name": "header"}, - {"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, - {"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, - {"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, - {"attributes": [{"name": "type", "value": "button"}], "name": "input"}, - {"attributes": [{"name": "type", "value": "image"}], "name": "input"}, - {"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, - {"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, - {"name": "button"}, - {"constraints": ["descendant of table"], "name": "td"}, - {"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}, - {"name": "th"}, - {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, - {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, - {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, - {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, - {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, - {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, - {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, - {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}, - {"name": "aside"}, - {"constraints": ["direct descendant of document"], "name": "footer"}, - {"name": "dd"}, - {"name": "dialog"}, - {"name": "body"}, - {"name": "figure"}, - {"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, - {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, - {"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}, - {"name": "span"}, - {"name": "div"}, - {"attributes": [{"name": "role", "value": "grid"}], "name": "table"}, - {"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}, - {"name": "details"}, - {"name": "fieldset"}, - {"name": "optgroup"}, - {"name": "h1"}, - {"name": "h2"}, - {"name": "h3"}, - {"name": "h4"}, - {"name": "h5"}, - {"name": "h6"}, - {"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, - {"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}, - {"attributes": [{"name": "href"}], "name": "a"}, - {"attributes": [{"name": "href"}], "name": "area"}, - {"attributes": [{"name": "href"}], "name": "link"}, - {"name": "menu"}, - {"name": "ol"}, - {"name": "ul"}, - {"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, - {"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, - {"attributes": [{"name": "multiple"}], "name": "select"}, - {"name": "datalist"}, - {"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}, - {"name": "main"}, - {"name": "math"}, - {"name": "menuitem"}, - {"name": "nav"}, - {"name": "option"}, - {"name": "progress"}, - {"attributes": [{"name": "type", "value": "radio"}], "name": "input"}, - {"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, - {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, - {"name": "frame"}, - {"name": "tr"}, - {"name": "tbody"}, - {"name": "tfoot"}, - {"name": "thead"}, - {"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, - {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, - {"name": "hr"}, - {"attributes": [{"name": "type", "value": "range"}], "name": "input"}, - {"attributes": [{"name": "type", "value": "number"}], "name": "input"}, - {"name": "output"}, - {"name": "table"}, - {"name": "dfn"}, - {"name": "dt"}, - {"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, - {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, - {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, - {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, - {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, - {"name": "textarea"}, - ] - ) - ); - expect([...elementRoleMap.keys()]).toEqual( - expect.arrayContaining( - [ - {"name": "menuitem"}, - {"name": "rel"}, - {"name": "article"}, - {"constraints": ["direct descendant of document"], "name": "header"}, - {"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, - {"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, - {"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, - {"attributes": [{"name": "type", "value": "button"}], "name": "input"}, - {"attributes": [{"name": "type", "value": "image"}], "name": "input"}, - {"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, - {"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, - {"name": "button"}, - {"constraints": ["descendant of table"], "name": "td"}, - {"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}, - {"name": "th"}, - {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, - {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, - {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, - {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, - {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, - {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, - {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, - {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}, - {"name": "aside"}, - {"constraints": ["direct descendant of document"], "name": "footer"}, - {"name": "dd"}, - {"name": "dialog"}, - {"name": "body"}, - {"name": "figure"}, - {"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, - {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, - {"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}, - {"name": "span"}, - {"name": "div"}, - {"attributes": [{"name": "role", "value": "grid"}], "name": "table"}, - {"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}, - {"name": "details"}, - {"name": "fieldset"}, - {"name": "optgroup"}, - {"name": "h1"}, - {"name": "h2"}, - {"name": "h3"}, - {"name": "h4"}, - {"name": "h5"}, - {"name": "h6"}, - {"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, - {"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}, - {"attributes": [{"name": "href"}], "name": "a"}, - {"attributes": [{"name": "href"}], "name": "area"}, - {"attributes": [{"name": "href"}], "name": "link"}, - {"name": "menu"}, - {"name": "ol"}, - {"name": "ul"}, - {"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, - {"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, - {"attributes": [{"name": "multiple"}], "name": "select"}, - {"name": "datalist"}, - {"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}, - {"name": "main"}, - {"name": "math"}, - {"name": "menuitem"}, - {"name": "nav"}, - {"name": "option"}, - {"name": "progress"}, - {"attributes": [{"name": "type", "value": "radio"}], "name": "input"}, - {"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, - {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, - {"name": "frame"}, - {"name": "tr"}, - {"name": "tbody"}, - {"name": "tfoot"}, - {"name": "thead"}, - {"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, - {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, - {"name": "hr"}, - {"attributes": [{"name": "type", "value": "range"}], "name": "input"}, - {"attributes": [{"name": "type", "value": "number"}], "name": "input"}, - {"name": "output"}, - {"name": "table"}, - {"name": "dfn"}, - {"name": "dt"}, - {"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, - {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, - {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, - {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, - {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, - {"name": "textarea"}, - ] - ) - ); + describe('keys()', function () { + const entriesKeys = entriesList.map(entry => entry[0]); + test.each(elementRoleMap.keys())('Testing key: %o', (key) => { + expect(entriesKeys).toEqual( + expect.arrayContaining([key]), + ); + }); + test.each([...elementRoleMap.keys()])('Testing key: %o', (key) => { + expect(entriesKeys).toEqual( + expect.arrayContaining([key]), + ); + }); }); - it('values', function () { - expect(elementRoleMap.values()).toEqual( - expect.arrayContaining( - [ - ["command", "menuitem"], - ["roletype"], - ["article"], - ["banner"], - ["button"], - ["button"], - ["button"], - ["button"], - ["button"], - ["button"], - ["button"], - ["button"], - ["cell"], - ["checkbox"], - ["columnheader"], - ["combobox"], - ["combobox"], - ["combobox"], - ["combobox"], - ["combobox"], - ["combobox"], - ["combobox"], - ["combobox"], - ["complementary"], - ["contentinfo"], - ["definition"], - ["dialog"], - ["document"], - ["figure"], - ["form"], - ["form"], - ["form"], - ["generic"], - ["generic"], - ["grid"], - ["gridcell"], - ["group"], - ["group"], - ["group"], - ["heading"], - ["heading"], - ["heading"], - ["heading"], - ["heading"], - ["heading"], - ["img"], - ["img"], - ["link"], - ["link"], - ["link"], - ["list"], - ["list"], - ["list"], - ["listbox"], - ["listbox"], - ["listbox"], - ["listbox"], - ["listitem"], - ["main"], - ["math"], - ["command", "menuitem"], - ["navigation"], - ["option"], - ["progressbar"], - ["radio"], - ["region"], - ["region"], - ["region"], - ["row"], - ["rowgroup"], - ["rowgroup"], - ["rowgroup"], - ["rowheader"], - ["searchbox"], - ["separator"], - ["slider"], - ["spinbutton"], - ["status"], - ["table"], - ["term"], - ["term"], - ["textbox"], - ["textbox"], - ["textbox"], - ["textbox"], - ["textbox"], - ["textbox"], - ] - ) - ); - expect([...elementRoleMap.values()]).toEqual( - expect.arrayContaining( - [ - ["command", "menuitem"], - ["roletype"], - ["article"], - ["banner"], - ["button"], - ["button"], - ["button"], - ["button"], - ["button"], - ["button"], - ["button"], - ["button"], - ["cell"], - ["checkbox"], - ["columnheader"], - ["combobox"], - ["combobox"], - ["combobox"], - ["combobox"], - ["combobox"], - ["combobox"], - ["combobox"], - ["combobox"], - ["complementary"], - ["contentinfo"], - ["definition"], - ["dialog"], - ["document"], - ["figure"], - ["form"], - ["form"], - ["form"], - ["generic"], - ["generic"], - ["grid"], - ["gridcell"], - ["group"], - ["group"], - ["group"], - ["heading"], - ["heading"], - ["heading"], - ["heading"], - ["heading"], - ["heading"], - ["img"], - ["img"], - ["link"], - ["link"], - ["link"], - ["list"], - ["list"], - ["list"], - ["listbox"], - ["listbox"], - ["listbox"], - ["listbox"], - ["listitem"], - ["main"], - ["math"], - ["command", "menuitem"], - ["navigation"], - ["option"], - ["progressbar"], - ["radio"], - ["region"], - ["region"], - ["region"], - ["row"], - ["rowgroup"], - ["rowgroup"], - ["rowgroup"], - ["rowheader"], - ["searchbox"], - ["separator"], - ["slider"], - ["spinbutton"], - ["status"], - ["table"], - ["term"], - ["term"], - ["textbox"], - ["textbox"], - ["textbox"], - ["textbox"], - ["textbox"], - ["textbox"], - ] - ) - ); + describe('values()', function () { + const entriesValues = entriesList.map(entry => entry[1]); + test.each(elementRoleMap.values().map(value => [value]))('Testing value: %o', (value) => { + expect(entriesValues).toEqual( + expect.arrayContaining([value]), + ); + }); + test.each([...elementRoleMap.values()].map(value => [value]))('Testing value: %o', (value) => { + expect(entriesValues).toEqual( + expect.arrayContaining([value]), + ); + }); }); }); @@ -809,293 +227,26 @@ describe('elementRolesMap', function () { it('should have an iterator defined', function () { expect(elementRoleMap[Symbol.iterator]).not.toBeUndefined(); }); - it('should support the spread operator', function () { - expect([...elementRoleMap].length).toEqual(88); - expect(elementRoleMap.entries()).toEqual( - expect.arrayContaining( - [ - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "rel"}, ["roletype"]], - [{"name": "article"}, ["article"]], - [{"constraints": ["direct descendant of document"], "name": "header"}, ["banner"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "type", "value": "button"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "image"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, ["button"]], - [{"name": "button"}, ["button"]], - [{"constraints": ["descendant of table"], "name": "td"}, ["cell"]], - [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}, ["checkbox"]], - [{"name": "th"}, ["columnheader"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}, ["combobox"]], - [{"name": "aside"}, ["complementary"]], - [{"constraints": ["direct descendant of document"], "name": "footer"}, ["contentinfo"]], - [{"name": "dd"}, ["definition"]], - [{"name": "dialog"}, ["dialog"]], - [{"name": "body"}, ["document"]], - [{"name": "figure"}, ["figure"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}, ["form"]], - [{"name": "span"}, ["generic"]], - [{"name": "div"}, ["generic"]], - [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}, ["grid"]], - [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}, ["gridcell"]], - [{"name": "details"}, ["group"]], - [{"name": "fieldset"}, ["group"]], - [{"name": "optgroup"}, ["group"]], - [{"name": "h1"}, ["heading"]], - [{"name": "h2"}, ["heading"]], - [{"name": "h3"}, ["heading"]], - [{"name": "h4"}, ["heading"]], - [{"name": "h5"}, ["heading"]], - [{"name": "h6"}, ["heading"]], - [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"name": "href"}], "name": "a"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "area"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "link"}, ["link"]], - [{"name": "menu"}, ["list"]], - [{"name": "ol"}, ["list"]], - [{"name": "ul"}, ["list"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"name": "datalist"}, ["listbox"]], - [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}, ["listitem"]], - [{"name": "main"}, ["main"]], - [{"name": "math"}, ["math"]], - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "nav"}, ["navigation"]], - [{"name": "option"}, ["option"]], - [{"name": "progress"}, ["progressbar"]], - [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}, ["radio"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, ["region"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, ["region"]], - [{"name": "frame"}, ["region"]], - [{"name": "tr"}, ["row"]], - [{"name": "tbody"}, ["rowgroup"]], - [{"name": "tfoot"}, ["rowgroup"]], - [{"name": "thead"}, ["rowgroup"]], - [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, ["rowheader"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["searchbox"]], - [{"name": "hr"}, ["separator"]], - [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}, ["slider"]], - [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}, ["spinbutton"]], - [{"name": "output"}, ["status"]], - [{"name": "table"}, ["table"]], - [{"name": "dfn"}, ["term"]], - [{"name": "dt"}, ["term"]], - [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["textbox"]], - [{"name": "textarea"}, ["textbox"]] - ] - ) - ); - expect([...elementRoleMap]).toEqual( - expect.arrayContaining( - [ - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "rel"}, ["roletype"]], - [{"name": "article"}, ["article"]], - [{"constraints": ["direct descendant of document"], "name": "header"}, ["banner"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "type", "value": "button"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "image"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, ["button"]], - [{"name": "button"}, ["button"]], - [{"constraints": ["descendant of table"], "name": "td"}, ["cell"]], - [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}, ["checkbox"]], - [{"name": "th"}, ["columnheader"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}, ["combobox"]], - [{"name": "aside"}, ["complementary"]], - [{"constraints": ["direct descendant of document"], "name": "footer"}, ["contentinfo"]], - [{"name": "dd"}, ["definition"]], - [{"name": "dialog"}, ["dialog"]], - [{"name": "body"}, ["document"]], - [{"name": "figure"}, ["figure"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}, ["form"]], - [{"name": "span"}, ["generic"]], - [{"name": "div"}, ["generic"]], - [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}, ["grid"]], - [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}, ["gridcell"]], - [{"name": "details"}, ["group"]], - [{"name": "fieldset"}, ["group"]], - [{"name": "optgroup"}, ["group"]], - [{"name": "h1"}, ["heading"]], - [{"name": "h2"}, ["heading"]], - [{"name": "h3"}, ["heading"]], - [{"name": "h4"}, ["heading"]], - [{"name": "h5"}, ["heading"]], - [{"name": "h6"}, ["heading"]], - [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"name": "href"}], "name": "a"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "area"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "link"}, ["link"]], - [{"name": "menu"}, ["list"]], - [{"name": "ol"}, ["list"]], - [{"name": "ul"}, ["list"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"name": "datalist"}, ["listbox"]], - [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}, ["listitem"]], - [{"name": "main"}, ["main"]], - [{"name": "math"}, ["math"]], - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "nav"}, ["navigation"]], - [{"name": "option"}, ["option"]], - [{"name": "progress"}, ["progressbar"]], - [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}, ["radio"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, ["region"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, ["region"]], - [{"name": "frame"}, ["region"]], - [{"name": "tr"}, ["row"]], - [{"name": "tbody"}, ["rowgroup"]], - [{"name": "tfoot"}, ["rowgroup"]], - [{"name": "thead"}, ["rowgroup"]], - [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, ["rowheader"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["searchbox"]], - [{"name": "hr"}, ["separator"]], - [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}, ["slider"]], - [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}, ["spinbutton"]], - [{"name": "output"}, ["status"]], - [{"name": "table"}, ["table"]], - [{"name": "dfn"}, ["term"]], - [{"name": "dt"}, ["term"]], - [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["textbox"]], - [{"name": "textarea"}, ["textbox"]] - ] - ) - ); + describe('spread operator', function () { + it('should have a specific length', function () { + expect([...elementRoleMap].length).toEqual(118); + }); + test.each([...elementRoleMap])('Testing element: %o', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); - it('should support the for..of pattern', function () { + describe('for..of pattern', function () { const output = []; for (const [key, value] of elementRoleMap) { output.push([key, value]); } - expect(output).toEqual( - expect.arrayContaining( - [ - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "rel"}, ["roletype"]], - [{"name": "article"}, ["article"]], - [{"constraints": ["direct descendant of document"], "name": "header"}, ["banner"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, ["button"]], - [{"attributes": [{"name": "type", "value": "button"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "image"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, ["button"]], - [{"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, ["button"]], - [{"name": "button"}, ["button"]], - [{"constraints": ["descendant of table"], "name": "td"}, ["cell"]], - [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}, ["checkbox"]], - [{"name": "th"}, ["columnheader"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, ["combobox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}, ["combobox"]], - [{"name": "aside"}, ["complementary"]], - [{"constraints": ["direct descendant of document"], "name": "footer"}, ["contentinfo"]], - [{"name": "dd"}, ["definition"]], - [{"name": "dialog"}, ["dialog"]], - [{"name": "body"}, ["document"]], - [{"name": "figure"}, ["figure"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, ["form"]], - [{"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}, ["form"]], - [{"name": "span"}, ["generic"]], - [{"name": "div"}, ["generic"]], - [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}, ["grid"]], - [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}, ["gridcell"]], - [{"name": "details"}, ["group"]], - [{"name": "fieldset"}, ["group"]], - [{"name": "optgroup"}, ["group"]], - [{"name": "h1"}, ["heading"]], - [{"name": "h2"}, ["heading"]], - [{"name": "h3"}, ["heading"]], - [{"name": "h4"}, ["heading"]], - [{"name": "h5"}, ["heading"]], - [{"name": "h6"}, ["heading"]], - [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}, ["img"]], - [{"attributes": [{"name": "href"}], "name": "a"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "area"}, ["link"]], - [{"attributes": [{"name": "href"}], "name": "link"}, ["link"]], - [{"name": "menu"}, ["list"]], - [{"name": "ol"}, ["list"]], - [{"name": "ul"}, ["list"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, ["listbox"]], - [{"attributes": [{"name": "multiple"}], "name": "select"}, ["listbox"]], - [{"name": "datalist"}, ["listbox"]], - [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}, ["listitem"]], - [{"name": "main"}, ["main"]], - [{"name": "math"}, ["math"]], - [{"name": "menuitem"}, ["command", "menuitem"]], - [{"name": "nav"}, ["navigation"]], - [{"name": "option"}, ["option"]], - [{"name": "progress"}, ["progressbar"]], - [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}, ["radio"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, ["region"]], - [{"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, ["region"]], - [{"name": "frame"}, ["region"]], - [{"name": "tr"}, ["row"]], - [{"name": "tbody"}, ["rowgroup"]], - [{"name": "tfoot"}, ["rowgroup"]], - [{"name": "thead"}, ["rowgroup"]], - [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, ["rowheader"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, ["searchbox"]], - [{"name": "hr"}, ["separator"]], - [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}, ["slider"]], - [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}, ["spinbutton"]], - [{"name": "output"}, ["status"]], - [{"name": "table"}, ["table"]], - [{"name": "dfn"}, ["term"]], - [{"name": "dt"}, ["term"]], - [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, ["textbox"]], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, ["textbox"]], - [{"name": "textarea"}, ["textbox"]] - ] - ) - ); + test.each(output)('Testing element: %o', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); }); }); diff --git a/__tests__/src/roleElementMap-test.js b/__tests__/src/roleElementMap-test.js index cbb93ad8..bb942858 100644 --- a/__tests__/src/roleElementMap-test.js +++ b/__tests__/src/roleElementMap-test.js @@ -1,112 +1,81 @@ import expect from 'expect'; import roleElementMap from '../../src/roleElementMap'; +const entriesList = [ + ["article", [{"name": "article"}]], + ["banner", [{"constraints": ["scoped to the body element"], "name": "header"}]], + ["blockquote", [{"name": "blockquote"}]], + ["button", [{"attributes": [{"name": "type", "value": "button"}], "name": "input"}, {"attributes": [{"name": "type", "value": "image"}], "name": "input"}, {"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, {"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, {"name": "button"}]], + ["caption", [{"name": "caption"}]], + ["cell", [{"constraints": ["ancestor table element has table role"], "name": "td"}]], + ["checkbox", [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}]], + ["code", [{"name": "code"}]], + ["columnheader", [{"name": "th"}, {"attributes": [{"name": "scope", "value": "col"}], "name": "th"}, {"attributes": [{"name": "scope", "value": "colgroup"}], "name": "th"}]], + ["combobox", [{"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "email"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, {"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "search"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, {"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "tel"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, {"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "text"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, {"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "url"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, {"attributes": [{"name": "aria-controls"}, {"name": "list"}, {"name": "type", "value": "url"}], "constraints": ["the aria-controls attribute is set to the same value as the list attribute"], "name": "input"}, {"attributes": [{"name": "multiple"}, {"name": "size"}], "constraints": ["the multiple attribute and the size attribute do not have a value greater than 1"], "name": "select"}]], + ["complementary", [{"name": "aside"}, {"attributes": [{"name": "aria-label"}], "constraints": ["scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "aside"}, {"attributes": [{"name": "aria-labelledby"}], "constraints": ["scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "aside"}]], + ["contentinfo", [{"constraints": ["scoped to the body element"], "name": "footer"}]], + ["definition", [{"name": "dd"}]], + ["deletion", [{"name": "del"}]], + ["dialog", [{"name": "dialog"}]], + ["document", [{"name": "html"}]], + ["emphasis", [{"name": "em"}]], + ["figure", [{"name": "figure"}]], + ["form", [{"attributes": [{"name": "aria-label"}], "name": "form"}, {"attributes": [{"name": "aria-labelledby"}], "name": "form"}, {"attributes": [{"name": "name"}], "name": "form"}]], + ["generic", [{"name": "a"}, {"name": "area"}, {"name": "aside"}, {"name": "b"}, {"name": "bdo"}, {"name": "body"}, {"name": "data"}, {"name": "div"}, {"constraints": ["scoped to the main element", "scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "footer"}, {"constraints": ["scoped to the main element", "scoped to a sectioning content element", "scoped to a sectioning root element other than body"], "name": "header"}, {"name": "hgroup"}, {"name": "i"}, {"name": "pre"}, {"name": "q"}, {"name": "samp"}, {"name": "section"}, {"name": "small"}, {"name": "span"}, {"name": "u"}]], + ["grid", [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}]], + ["gridcell", [{"constraints": ["ancestor table element has grid role"], "name": "td"}]], + ["group", [{"name": "details"}, {"name": "fieldset"}, {"name": "optgroup"}, {"name": "address"}]], + ["heading", [{"name": "h1"}, {"name": "h2"}, {"name": "h3"}, {"name": "h4"}, {"name": "h5"}, {"name": "h6"}]], + ["img", [{"name": "img"}]], + ["insertion", [{"name": "ins"}]], + ["link", [{"attributes": [{"name": "href"}], "name": "a"}, {"attributes": [{"name": "href"}], "name": "area"}]], + ["list", [{"name": "menu"}, {"name": "ol"}, {"name": "ul"}]], + ["listbox", [{"attributes": [{"name": "size"}, {"name": "multiple"}], "constraints": ["the size attribute value is greater than 1"], "name": "select"}, {"attributes": [{"name": "size"}], "constraints": ["the size attribute value is greater than 1"], "name": "select"}, {"attributes": [{"name": "multiple"}], "constraints": ["the multiple attribute value is greater than 1"], "name": "select"}, {"attributes": [{"name": "aria-multiselectable", "value": "true"}], "constraints": ["the datalist selection model allows multiple option elements to be selected at a time"], "name": "datalist"}, {"attributes": [{"name": "aria-multiselectable", "value": "false"}], "name": "datalist"}]], + ["listitem", [{"constraints": ["direct descendant of ol", "direct descendant of ul", "direct descendant of menu"], "name": "li"}]], + ["main", [{"name": "main"}]], + ["mark", [{"name": "mark"}]], + ["math", [{"name": "math"}]], + ["meter", [{"name": "meter"}]], + ["navigation", [{"name": "nav"}]], + ["option", [{"name": "option"}]], + ["paragraph", [{"name": "p"}]], + ["presentation", [{"attributes": [{"name": "alt", "value": ""}], "name": "img"}]], + ["progressbar", [{"name": "progress"}, {"attributes": [{"name": "aria-valuemax"}, {"name": "aria-valuemin", "value": 0}, {"name": "aria-valuenow"}], "constraints": ["the progress bar is determinate"], "name": "progress"}]], + ["radio", [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}]], + ["region", [{"attributes": [{"name": "aria-label"}], "name": "section"}, {"attributes": [{"name": "aria-labelledby"}], "name": "section"}]], + ["row", [{"name": "tr"}]], + ["rowgroup", [{"name": "tbody"}, {"name": "tfoot"}, {"name": "thead"}]], + ["rowheader", [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, {"attributes": [{"name": "scope", "value": "rowgroup"}], "name": "th"}]], + ["section", [{"attributes": [{"name": "aria-label"}], "name": "section"}, {"attributes": [{"name": "aria-labelledby"}], "name": "section"}]], + ["searchbox", [{"attributes": [{"name": "list"}, {"name": "type", "value": "search"}], "constraints": ["the list attribute is not set"], "name": "input"}]], + ["separator", [{"name": "hr"}]], + ["slider", [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}]], + ["spinbutton", [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}]], + ["status", [{"name": "output"}]], + ["strong", [{"name": "strong"}]], + ["subscript", [{"name": "sub"}]], + ["superscript", [{"name": "sup"}]], + ["switch", [{"attributes": [{"name": "aria-checked"}], "name": "button"}]], + ["table", [{"name": "table"}]], + ["term", [{"name": "dfn"}, {"name": "dt"}]], + ["textbox", [{"constraints": ["the list attribute is not set"], "name": "input"}, {"attributes": [{"name": "type", "value": "email"}], "constraints": ["the list attribute is not set"], "name": "input"}, {"attributes": [{"name": "type", "value": "tel"}], "constraints": ["the list attribute is not set"], "name": "input"}, {"attributes": [{"name": "type", "value": "text"}], "constraints": ["the list attribute is not set"], "name": "input"}, {"attributes": [{"name": "type", "value": "url"}], "constraints": ["the list attribute is not set"], "name": "input"}, {"name": "textarea"}]], + ["time", [{"name": "time"}]], +]; + describe('roleElementMap API', function () { - it('entries', function () { - expect(roleElementMap.entries()).toEqual( - expect.arrayContaining( - [ - ["command", [{"name": "menuitem"}]], - ["roletype", [{"name": "rel"}]], - ["article", [{"name": "article"}]], - ["banner", [{"constraints": ["direct descendant of document"], "name": "header"}]], - ["button", [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, {"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, {"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, {"attributes": [{"name": "type", "value": "button"}], "name": "input"}, {"attributes": [{"name": "type", "value": "image"}], "name": "input"}, {"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, {"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, {"name": "button"}]], - ["cell", [{"constraints": ["descendant of table"], "name": "td"}]], - ["checkbox", [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}]], - ["columnheader", [{"name": "th"}]], - ["combobox", [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}]], - ["complementary", [{"name": "aside"}]], - ["contentinfo", [{"constraints": ["direct descendant of document"], "name": "footer"}]], - ["definition", [{"name": "dd"}]], - ["dialog", [{"name": "dialog"}]], - ["document", [{"name": "body"}]], - ["figure", [{"name": "figure"}]], - ["form", [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}]], - ["generic", [{"name": "span"}, {"name": "div"}]], - ["grid", [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}]], - ["gridcell", [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}]], - ["group", [{"name": "details"}, {"name": "fieldset"}, {"name": "optgroup"}]], - ["heading", [{"name": "h1"}, {"name": "h2"}, {"name": "h3"}, {"name": "h4"}, {"name": "h5"}, {"name": "h6"}]], - ["img", [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, {"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}]], - ["link", [{"attributes": [{"name": "href"}], "name": "a"}, {"attributes": [{"name": "href"}], "name": "area"}, {"attributes": [{"name": "href"}], "name": "link"}]], - ["list", [{"name": "menu"}, {"name": "ol"}, {"name": "ul"}]], - ["listbox", [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, {"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, {"attributes": [{"name": "multiple"}], "name": "select"}, {"name": "datalist"}]], - ["listitem", [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}]], - ["main", [{"name": "main"}]], - ["math", [{"name": "math"}]], - ["menuitem", [{"name": "menuitem"}]], - ["navigation", [{"name": "nav"}]], - ["option", [{"name": "option"}]], - ["progressbar", [{"name": "progress"}]], - ["radio", [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}]], - ["region", [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, {"name": "frame"}]], - ["row", [{"name": "tr"}]], - ["rowgroup", [{"name": "tbody"}, {"name": "tfoot"}, {"name": "thead"}]], - ["rowheader", [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, {"attributes": [{"name": "scope", "value": "rowgroup"}], "name": "th"}]], - ["searchbox", [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}]], - ["separator", [{"name": "hr"}]], - ["slider", [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}]], - ["spinbutton", [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}]], - ["status", [{"name": "output"}]], - ["table", [{"name": "table"}]], - ["term", [{"name": "dfn"}, {"name": "dt"}]], - ["textbox", [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"name": "textarea"}]] - ] - ) - ); - expect([...roleElementMap.entries()]).toEqual( - expect.arrayContaining( - [ - ["command", [{"name": "menuitem"}]], - ["roletype", [{"name": "rel"}]], - ["article", [{"name": "article"}]], - ["banner", [{"constraints": ["direct descendant of document"], "name": "header"}]], - ["button", [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, {"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, {"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, {"attributes": [{"name": "type", "value": "button"}], "name": "input"}, {"attributes": [{"name": "type", "value": "image"}], "name": "input"}, {"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, {"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, {"name": "button"}]], - ["cell", [{"constraints": ["descendant of table"], "name": "td"}]], - ["checkbox", [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}]], - ["columnheader", [{"name": "th"}]], - ["combobox", [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}]], - ["complementary", [{"name": "aside"}]], - ["contentinfo", [{"constraints": ["direct descendant of document"], "name": "footer"}]], - ["definition", [{"name": "dd"}]], - ["dialog", [{"name": "dialog"}]], - ["document", [{"name": "body"}]], - ["figure", [{"name": "figure"}]], - ["form", [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}]], - ["generic", [{"name": "span"}, {"name": "div"}]], - ["grid", [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}]], - ["gridcell", [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}]], - ["group", [{"name": "details"}, {"name": "fieldset"}, {"name": "optgroup"}]], - ["heading", [{"name": "h1"}, {"name": "h2"}, {"name": "h3"}, {"name": "h4"}, {"name": "h5"}, {"name": "h6"}]], - ["img", [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, {"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}]], - ["link", [{"attributes": [{"name": "href"}], "name": "a"}, {"attributes": [{"name": "href"}], "name": "area"}, {"attributes": [{"name": "href"}], "name": "link"}]], - ["list", [{"name": "menu"}, {"name": "ol"}, {"name": "ul"}]], - ["listbox", [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, {"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, {"attributes": [{"name": "multiple"}], "name": "select"}, {"name": "datalist"}]], - ["listitem", [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}]], - ["main", [{"name": "main"}]], - ["math", [{"name": "math"}]], - ["menuitem", [{"name": "menuitem"}]], - ["navigation", [{"name": "nav"}]], - ["option", [{"name": "option"}]], - ["progressbar", [{"name": "progress"}]], - ["radio", [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}]], - ["region", [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, {"name": "frame"}]], - ["row", [{"name": "tr"}]], - ["rowgroup", [{"name": "tbody"}, {"name": "tfoot"}, {"name": "thead"}]], - ["rowheader", [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, {"attributes": [{"name": "scope", "value": "rowgroup"}], "name": "th"}]], - ["searchbox", [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}]], - ["separator", [{"name": "hr"}]], - ["slider", [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}]], - ["spinbutton", [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}]], - ["status", [{"name": "output"}]], - ["table", [{"name": "table"}]], - ["term", [{"name": "dfn"}, {"name": "dt"}]], - ["textbox", [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"name": "textarea"}]] - ] - ) - ); + describe('entries()', function () { + test.each(roleElementMap.entries())(`Testing role: '%s' with element %o`, (role, elements) => { + expect(entriesList).toEqual( + expect.arrayContaining([[role, elements]]), + ); + }); + test.each([...roleElementMap.entries()])(`Testing role: '%s'`, (role, elements) => { + expect(entriesList).toEqual( + expect.arrayContaining([[role, elements]]), + ); + }); }); - it('forEach', function () { + describe('forEach()', function () { const output = []; let context; roleElementMap.forEach((value, key, map) => { @@ -115,377 +84,58 @@ describe('roleElementMap API', function () { context = map; } }); - expect(output).toEqual( - expect.arrayContaining( - [ - ["command", [{"name": "menuitem"}]], - ["roletype", [{"name": "rel"}]], - ["article", [{"name": "article"}]], - ["banner", [{"constraints": ["direct descendant of document"], "name": "header"}]], - ["button", [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, {"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, {"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, {"attributes": [{"name": "type", "value": "button"}], "name": "input"}, {"attributes": [{"name": "type", "value": "image"}], "name": "input"}, {"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, {"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, {"name": "button"}]], - ["cell", [{"constraints": ["descendant of table"], "name": "td"}]], - ["checkbox", [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}]], - ["columnheader", [{"name": "th"}]], - ["combobox", [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}]], - ["complementary", [{"name": "aside"}]], - ["contentinfo", [{"constraints": ["direct descendant of document"], "name": "footer"}]], - ["definition", [{"name": "dd"}]], - ["dialog", [{"name": "dialog"}]], - ["document", [{"name": "body"}]], - ["figure", [{"name": "figure"}]], - ["form", [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}]], - ["generic", [{"name": "span"}, {"name": "div"}]], - ["grid", [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}]], - ["gridcell", [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}]], - ["group", [{"name": "details"}, {"name": "fieldset"}, {"name": "optgroup"}]], - ["heading", [{"name": "h1"}, {"name": "h2"}, {"name": "h3"}, {"name": "h4"}, {"name": "h5"}, {"name": "h6"}]], - ["img", [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, {"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}]], - ["link", [{"attributes": [{"name": "href"}], "name": "a"}, {"attributes": [{"name": "href"}], "name": "area"}, {"attributes": [{"name": "href"}], "name": "link"}]], - ["list", [{"name": "menu"}, {"name": "ol"}, {"name": "ul"}]], - ["listbox", [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, {"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, {"attributes": [{"name": "multiple"}], "name": "select"}, {"name": "datalist"}]], - ["listitem", [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}]], - ["main", [{"name": "main"}]], - ["math", [{"name": "math"}]], - ["menuitem", [{"name": "menuitem"}]], - ["navigation", [{"name": "nav"}]], - ["option", [{"name": "option"}]], - ["progressbar", [{"name": "progress"}]], - ["radio", [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}]], - ["region", [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, {"name": "frame"}]], - ["row", [{"name": "tr"}]], - ["rowgroup", [{"name": "tbody"}, {"name": "tfoot"}, {"name": "thead"}]], - ["rowheader", [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, {"attributes": [{"name": "scope", "value": "rowgroup"}], "name": "th"}]], - ["searchbox", [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}]], - ["separator", [{"name": "hr"}]], - ["slider", [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}]], - ["spinbutton", [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}]], - ["status", [{"name": "output"}]], - ["table", [{"name": "table"}]], - ["term", [{"name": "dfn"}, {"name": "dt"}]], - ["textbox", [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"name": "textarea"}]] - ] - ) - ); - expect(context).toEqual( - expect.arrayContaining( - [ - ["command", [{"name": "menuitem"}]], - ["roletype", [{"name": "rel"}]], - ["article", [{"name": "article"}]], - ["banner", [{"constraints": ["direct descendant of document"], "name": "header"}]], - ["button", [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, {"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, {"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, {"attributes": [{"name": "type", "value": "button"}], "name": "input"}, {"attributes": [{"name": "type", "value": "image"}], "name": "input"}, {"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, {"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, {"name": "button"}]], - ["cell", [{"constraints": ["descendant of table"], "name": "td"}]], - ["checkbox", [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}]], - ["columnheader", [{"name": "th"}]], - ["combobox", [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}]], - ["complementary", [{"name": "aside"}]], - ["contentinfo", [{"constraints": ["direct descendant of document"], "name": "footer"}]], - ["definition", [{"name": "dd"}]], - ["dialog", [{"name": "dialog"}]], - ["document", [{"name": "body"}]], - ["figure", [{"name": "figure"}]], - ["form", [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}]], - ["generic", [{"name": "span"}, {"name": "div"}]], - ["grid", [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}]], - ["gridcell", [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}]], - ["group", [{"name": "details"}, {"name": "fieldset"}, {"name": "optgroup"}]], - ["heading", [{"name": "h1"}, {"name": "h2"}, {"name": "h3"}, {"name": "h4"}, {"name": "h5"}, {"name": "h6"}]], - ["img", [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, {"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}]], - ["link", [{"attributes": [{"name": "href"}], "name": "a"}, {"attributes": [{"name": "href"}], "name": "area"}, {"attributes": [{"name": "href"}], "name": "link"}]], - ["list", [{"name": "menu"}, {"name": "ol"}, {"name": "ul"}]], - ["listbox", [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, {"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, {"attributes": [{"name": "multiple"}], "name": "select"}, {"name": "datalist"}]], - ["listitem", [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}]], - ["main", [{"name": "main"}]], - ["math", [{"name": "math"}]], - ["menuitem", [{"name": "menuitem"}]], - ["navigation", [{"name": "nav"}]], - ["option", [{"name": "option"}]], - ["progressbar", [{"name": "progress"}]], - ["radio", [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}]], - ["region", [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, {"name": "frame"}]], - ["row", [{"name": "tr"}]], - ["rowgroup", [{"name": "tbody"}, {"name": "tfoot"}, {"name": "thead"}]], - ["rowheader", [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, {"attributes": [{"name": "scope", "value": "rowgroup"}], "name": "th"}]], - ["searchbox", [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}]], - ["separator", [{"name": "hr"}]], - ["slider", [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}]], - ["spinbutton", [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}]], - ["status", [{"name": "output"}]], - ["table", [{"name": "table"}]], - ["term", [{"name": "dfn"}, {"name": "dt"}]], - ["textbox", [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"name": "textarea"}]] - ] - ) - ); + test.each(output)(`Testing role: '%s' with element %O`, (role, elements) => { + expect(entriesList).toEqual( + expect.arrayContaining([[role, elements]]), + ); + }); + test.each(context)(`Testing role: '%s' with element %O`, (role, elements) => { + expect(entriesList).toEqual( + expect.arrayContaining([[role, elements]]), + ); + }); }); - it('get', function () { + it('get()', function () { expect(roleElementMap.get('button')).toEqual( - expect.arrayContaining( - [{ - "attributes": [{ - "constraints": ["set"], - "name": "aria-pressed" - }, { - "name": "type", - "value": "checkbox" - }], - "name": "input" - }, { - "attributes": [{ - "name": "aria-expanded", - "value": "false" - }], - "name": "summary" - }, { - "attributes": [{ - "name": "aria-expanded", - "value": "true" - }], - "constraints": [ - "direct descendant of details element with the open attribute defined" - ], - "name": "summary" - }, { - "attributes": [{ - "name": "type", - "value": "button" - }], - "name": "input" - }, { - "attributes": [{ - "name": "type", - "value": "image" - }], - "name": "input" - }, { - "attributes": [{ - "name": "type", - "value": "reset" - }], "name": "input" - }, { - "attributes": [{ - "name": "type", - "value": "submit" - }], - "name": "input" - }, { - "name": "button" - }], - ), + expect.arrayContaining([ + {"attributes": [{"name": "type", "value": "button"}], "name": "input"}, + {"attributes": [{"name": "type", "value": "image"}], "name": "input"}, + {"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, + {"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, + {"name": "button"} + ]), ); expect(roleElementMap.get('fake role')).toBeUndefined(); }); - it('has', function () { + it('has()', function () { expect(roleElementMap.has('button')).toEqual(true); expect(roleElementMap.has('fake role')).toEqual(false); }); - it('keys', function () { - expect(roleElementMap.keys()).toEqual( - expect.arrayContaining( - [ - "command", - "roletype", - "article", - "banner", - "button", - "cell", - "checkbox", - "columnheader", - "combobox", - "complementary", - "contentinfo", - "definition", - "dialog", - "document", - "figure", - "form", - "generic", - "grid", - "gridcell", - "group", - "heading", - "img", - "link", - "list", - "listbox", - "listitem", - "main", - "math", - "menuitem", - "navigation", - "option", - "progressbar", - "radio", - "region", - "row", - "rowgroup", - "rowheader", - "searchbox", - "separator", - "slider", - "spinbutton", - "status", - "table", - "term", - "textbox", - ] - ) - ); - expect([...roleElementMap.keys()]).toEqual( - expect.arrayContaining( - [ - "command", - "roletype", - "article", - "banner", - "button", - "cell", - "checkbox", - "columnheader", - "combobox", - "complementary", - "contentinfo", - "definition", - "dialog", - "document", - "figure", - "form", - "generic", - "grid", - "gridcell", - "group", - "heading", - "img", - "link", - "list", - "listbox", - "listitem", - "main", - "math", - "menuitem", - "navigation", - "option", - "progressbar", - "radio", - "region", - "row", - "rowgroup", - "rowheader", - "searchbox", - "separator", - "slider", - "spinbutton", - "status", - "table", - "term", - "textbox", - ] - ) - ); + describe('keys()', function () { + const entriesKeys = entriesList.map(entry => entry[0]); + test.each(roleElementMap.keys())('Testing key: %o', (key) => { + expect(entriesKeys).toEqual( + expect.arrayContaining([key]), + ); + }); + test.each([...roleElementMap.keys()])('Testing key: %o', (key) => { + expect(entriesKeys).toEqual( + expect.arrayContaining([key]), + ); + }); }); - it('values', function () { - expect(roleElementMap.values()).toEqual( - expect.arrayContaining( - [ - [{"name": "menuitem"}], - [{"name": "rel"}], - [{"name": "article"}], - [{"constraints": ["direct descendant of document"], "name": "header"}], - [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, {"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, {"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, {"attributes": [{"name": "type", "value": "button"}], "name": "input"}, {"attributes": [{"name": "type", "value": "image"}], "name": "input"}, {"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, {"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, {"name": "button"}], - [{"constraints": ["descendant of table"], "name": "td"}], - [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}], - [{"name": "th"}], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}], - [{"name": "aside"}], - [{"constraints": ["direct descendant of document"], "name": "footer"}], - [{"name": "dd"}], - [{"name": "dialog"}], - [{"name": "body"}], - [{"name": "figure"}], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}], - [{"name": "span"}, {"name": "div"}], - [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}], - [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}], - [{"name": "details"}, {"name": "fieldset"}, {"name": "optgroup"}], - [{"name": "h1"}, {"name": "h2"}, {"name": "h3"}, {"name": "h4"}, {"name": "h5"}, {"name": "h6"}], - [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, {"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}], - [{"attributes": [{"name": "href"}], "name": "a"}, {"attributes": [{"name": "href"}], "name": "area"}, {"attributes": [{"name": "href"}], "name": "link"}], - [{"name": "menu"}, {"name": "ol"}, {"name": "ul"}], - [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, {"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, {"attributes": [{"name": "multiple"}], "name": "select"}, {"name": "datalist"}], - [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}], - [{"name": "main"}], - [{"name": "math"}], - [{"name": "menuitem"}], - [{"name": "nav"}], - [{"name": "option"}], - [{"name": "progress"}], - [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, {"name": "frame"}], - [{"name": "tr"}], - [{"name": "tbody"}, {"name": "tfoot"}, {"name": "thead"}], - [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, {"attributes": [{"name": "scope", "value": "rowgroup"}], "name": "th"}], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}], - [{"name": "hr"}], - [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}], - [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}], - [{"name": "output"}], - [{"name": "table"}], - [{"name": "dfn"}, {"name": "dt"}], - [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"name": "textarea"}], - ], - ) - ); - expect([...roleElementMap.values()]).toEqual( - expect.arrayContaining( - [ - [{"name": "menuitem"}], - [{"name": "rel"}], - [{"name": "article"}], - [{"constraints": ["direct descendant of document"], "name": "header"}], - [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, {"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, {"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, {"attributes": [{"name": "type", "value": "button"}], "name": "input"}, {"attributes": [{"name": "type", "value": "image"}], "name": "input"}, {"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, {"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, {"name": "button"}], - [{"constraints": ["descendant of table"], "name": "td"}], - [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}], - [{"name": "th"}], - [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}], - [{"name": "aside"}], - [{"constraints": ["direct descendant of document"], "name": "footer"}], - [{"name": "dd"}], - [{"name": "dialog"}], - [{"name": "body"}], - [{"name": "figure"}], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}], - [{"name": "span"}, {"name": "div"}], - [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}], - [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}], - [{"name": "details"}, {"name": "fieldset"}, {"name": "optgroup"}], - [{"name": "h1"}, {"name": "h2"}, {"name": "h3"}, {"name": "h4"}, {"name": "h5"}, {"name": "h6"}], - [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, {"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}], - [{"attributes": [{"name": "href"}], "name": "a"}, {"attributes": [{"name": "href"}], "name": "area"}, {"attributes": [{"name": "href"}], "name": "link"}], - [{"name": "menu"}, {"name": "ol"}, {"name": "ul"}], - [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, {"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, {"attributes": [{"name": "multiple"}], "name": "select"}, {"name": "datalist"}], - [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}], - [{"name": "main"}], - [{"name": "math"}], - [{"name": "menuitem"}], - [{"name": "nav"}], - [{"name": "option"}], - [{"name": "progress"}], - [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}], - [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, {"name": "frame"}], - [{"name": "tr"}], - [{"name": "tbody"}, {"name": "tfoot"}, {"name": "thead"}], - [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, {"attributes": [{"name": "scope", "value": "rowgroup"}], "name": "th"}], - [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}], - [{"name": "hr"}], - [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}], - [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}], - [{"name": "output"}], - [{"name": "table"}], - [{"name": "dfn"}, {"name": "dt"}], - [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"name": "textarea"}], - ], - ) - ); + describe('values()', function () { + const entriesValues = entriesList.map(entry => entry[1]); + test.each(roleElementMap.values().map(value => [value]))('Testing value: %o', (value) => { + expect(entriesValues).toEqual( + expect.arrayContaining([value]), + ); + }); + test.each([...roleElementMap.values()].map(value => [value]))('Testing value: %o', (value) => { + expect(entriesValues).toEqual( + expect.arrayContaining([value]), + ); + }); }); }); @@ -494,116 +144,26 @@ describe('roleElementMap', function () { it('should have an iterator defined', function () { expect(roleElementMap[Symbol.iterator]).not.toBeUndefined(); }); - it('should support the spread operator', function () { - expect([...roleElementMap].length).toEqual(88); - expect([...roleElementMap]).toEqual( - expect.arrayContaining( - [ - ["command", [{"name": "menuitem"}]], - ["roletype", [{"name": "rel"}]], - ["article", [{"name": "article"}]], - ["banner", [{"constraints": ["direct descendant of document"], "name": "header"}]], - ["button", [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, {"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, {"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, {"attributes": [{"name": "type", "value": "button"}], "name": "input"}, {"attributes": [{"name": "type", "value": "image"}], "name": "input"}, {"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, {"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, {"name": "button"}]], - ["cell", [{"constraints": ["descendant of table"], "name": "td"}]], - ["checkbox", [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}]], - ["columnheader", [{"name": "th"}]], - ["combobox", [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}]], - ["complementary", [{"name": "aside"}]], - ["contentinfo", [{"constraints": ["direct descendant of document"], "name": "footer"}]], - ["definition", [{"name": "dd"}]], - ["dialog", [{"name": "dialog"}]], - ["document", [{"name": "body"}]], - ["figure", [{"name": "figure"}]], - ["form", [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}]], - ["generic", [{"name": "span"}, {"name": "div"}]], - ["grid", [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}]], - ["gridcell", [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}]], - ["group", [{"name": "details"}, {"name": "fieldset"}, {"name": "optgroup"}]], - ["heading", [{"name": "h1"}, {"name": "h2"}, {"name": "h3"}, {"name": "h4"}, {"name": "h5"}, {"name": "h6"}]], - ["img", [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, {"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}]], - ["link", [{"attributes": [{"name": "href"}], "name": "a"}, {"attributes": [{"name": "href"}], "name": "area"}, {"attributes": [{"name": "href"}], "name": "link"}]], - ["list", [{"name": "menu"}, {"name": "ol"}, {"name": "ul"}]], - ["listbox", [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, {"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, {"attributes": [{"name": "multiple"}], "name": "select"}, {"name": "datalist"}]], - ["listitem", [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}]], - ["main", [{"name": "main"}]], - ["math", [{"name": "math"}]], - ["menuitem", [{"name": "menuitem"}]], - ["navigation", [{"name": "nav"}]], - ["option", [{"name": "option"}]], - ["progressbar", [{"name": "progress"}]], - ["radio", [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}]], - ["region", [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, {"name": "frame"}]], - ["row", [{"name": "tr"}]], - ["rowgroup", [{"name": "tbody"}, {"name": "tfoot"}, {"name": "thead"}]], - ["rowheader", [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, {"attributes": [{"name": "scope", "value": "rowgroup"}], "name": "th"}]], - ["searchbox", [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}]], - ["separator", [{"name": "hr"}]], - ["slider", [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}]], - ["spinbutton", [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}]], - ["status", [{"name": "output"}]], - ["table", [{"name": "table"}]], - ["term", [{"name": "dfn"}, {"name": "dt"}]], - ["textbox", [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"name": "textarea"}]] - ] - ) - ); + describe('spread operator', function () { + it('should have a specific length', function () { + expect([...roleElementMap].length).toEqual(57); + }); + test.each([...roleElementMap])('Testing element: %o', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); - it('should support the for..of pattern', function () { + describe('for..of pattern', function () { const output = []; for (const [key, value] of roleElementMap) { output.push([key, value]); } - expect(output).toEqual( - expect.arrayContaining( - [ - ["command", [{"name": "menuitem"}]], - ["roletype", [{"name": "rel"}]], - ["article", [{"name": "article"}]], - ["banner", [{"constraints": ["direct descendant of document"], "name": "header"}]], - ["button", [{"attributes": [{"constraints": ["set"], "name": "aria-pressed"}, {"name": "type", "value": "checkbox"}], "name": "input"}, {"attributes": [{"name": "aria-expanded", "value": "false"}], "name": "summary"}, {"attributes": [{"name": "aria-expanded", "value": "true"}], "constraints": ["direct descendant of details element with the open attribute defined"], "name": "summary"}, {"attributes": [{"name": "type", "value": "button"}], "name": "input"}, {"attributes": [{"name": "type", "value": "image"}], "name": "input"}, {"attributes": [{"name": "type", "value": "reset"}], "name": "input"}, {"attributes": [{"name": "type", "value": "submit"}], "name": "input"}, {"name": "button"}]], - ["cell", [{"constraints": ["descendant of table"], "name": "td"}]], - ["checkbox", [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}]], - ["columnheader", [{"name": "th"}]], - ["combobox", [{"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["set"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"constraints": ["undefined"], "name": "size"}], "name": "select"}, {"attributes": [{"constraints": ["undefined"], "name": "multiple"}, {"name": "size", "value": 1}], "name": "select"}]], - ["complementary", [{"name": "aside"}]], - ["contentinfo", [{"constraints": ["direct descendant of document"], "name": "footer"}]], - ["definition", [{"name": "dd"}]], - ["dialog", [{"name": "dialog"}]], - ["document", [{"name": "body"}]], - ["figure", [{"name": "figure"}]], - ["form", [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "form"}, {"attributes": [{"constraints": ["set"], "name": "name"}], "name": "form"}]], - ["generic", [{"name": "span"}, {"name": "div"}]], - ["grid", [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}]], - ["gridcell", [{"attributes": [{"name": "role", "value": "gridcell"}], "name": "td"}]], - ["group", [{"name": "details"}, {"name": "fieldset"}, {"name": "optgroup"}]], - ["heading", [{"name": "h1"}, {"name": "h2"}, {"name": "h3"}, {"name": "h4"}, {"name": "h5"}, {"name": "h6"}]], - ["img", [{"attributes": [{"constraints": ["set"], "name": "alt"}], "name": "img"}, {"attributes": [{"constraints": ["undefined"], "name": "alt"}], "name": "img"}]], - ["link", [{"attributes": [{"name": "href"}], "name": "a"}, {"attributes": [{"name": "href"}], "name": "area"}, {"attributes": [{"name": "href"}], "name": "link"}]], - ["list", [{"name": "menu"}, {"name": "ol"}, {"name": "ul"}]], - ["listbox", [{"attributes": [{"constraints": [">1"], "name": "size"}, {"name": "multiple"}], "name": "select"}, {"attributes": [{"constraints": [">1"], "name": "size"}], "name": "select"}, {"attributes": [{"name": "multiple"}], "name": "select"}, {"name": "datalist"}]], - ["listitem", [{"constraints": ["direct descendant of ol, ul or menu"], "name": "li"}]], - ["main", [{"name": "main"}]], - ["math", [{"name": "math"}]], - ["menuitem", [{"name": "menuitem"}]], - ["navigation", [{"name": "nav"}]], - ["option", [{"name": "option"}]], - ["progressbar", [{"name": "progress"}]], - ["radio", [{"attributes": [{"name": "type", "value": "radio"}], "name": "input"}]], - ["region", [{"attributes": [{"constraints": ["set"], "name": "aria-label"}], "name": "section"}, {"attributes": [{"constraints": ["set"], "name": "aria-labelledby"}], "name": "section"}, {"name": "frame"}]], - ["row", [{"name": "tr"}]], - ["rowgroup", [{"name": "tbody"}, {"name": "tfoot"}, {"name": "thead"}]], - ["rowheader", [{"attributes": [{"name": "scope", "value": "row"}], "name": "th"}, {"attributes": [{"name": "scope", "value": "rowgroup"}], "name": "th"}]], - ["searchbox", [{"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "search"}], "name": "input"}]], - ["separator", [{"name": "hr"}]], - ["slider", [{"attributes": [{"name": "type", "value": "range"}], "name": "input"}]], - ["spinbutton", [{"attributes": [{"name": "type", "value": "number"}], "name": "input"}]], - ["status", [{"name": "output"}]], - ["table", [{"name": "table"}]], - ["term", [{"name": "dfn"}, {"name": "dt"}]], - ["textbox", [{"attributes": [{"constraints": ["undefined"], "name": "type"}, {"constraints": ["undefined"], "name": "list"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "email"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "tel"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "text"}], "name": "input"}, {"attributes": [{"constraints": ["undefined"], "name": "list"}, {"name": "type", "value": "url"}], "name": "input"}, {"name": "textarea"}]] - ] - ) - ); + test.each(output)('Testing element: %o', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); }); }); diff --git a/__tests__/src/rolesMap-test.js b/__tests__/src/rolesMap-test.js index a9430412..ab94c19a 100644 --- a/__tests__/src/rolesMap-test.js +++ b/__tests__/src/rolesMap-test.js @@ -2,288 +2,160 @@ import expect from 'expect'; import rolesMap from '../../src/rolesMap'; import ariaPropsMap from '../../src/ariaPropsMap'; +const entriesList = [ + ["alert", expect.any(Object)], + ["alertdialog", expect.any(Object)], + ["application", expect.any(Object)], + ["article", expect.any(Object)], + ["banner", expect.any(Object)], + ["blockquote", expect.any(Object)], + ["button", expect.any(Object)], + ["caption", expect.any(Object)], + ["cell", expect.any(Object)], + ["checkbox", expect.any(Object)], + ["code", expect.any(Object)], + ["columnheader", expect.any(Object)], + ["combobox", expect.any(Object)], + ["command", expect.any(Object)], + ["complementary", expect.any(Object)], + ["composite", expect.any(Object)], + ["contentinfo", expect.any(Object)], + ["definition", expect.any(Object)], + ["deletion", expect.any(Object)], + ["dialog", expect.any(Object)], + ["directory", expect.any(Object)], + ["document", expect.any(Object)], + ["emphasis", expect.any(Object)], + ["feed", expect.any(Object)], + ["figure", expect.any(Object)], + ["form", expect.any(Object)], + ["generic", expect.any(Object)], + ["grid", expect.any(Object)], + ["gridcell", expect.any(Object)], + ["group", expect.any(Object)], + ["heading", expect.any(Object)], + ["img", expect.any(Object)], + ["input", expect.any(Object)], + ["insertion", expect.any(Object)], + ["landmark", expect.any(Object)], + ["link", expect.any(Object)], + ["list", expect.any(Object)], + ["listbox", expect.any(Object)], + ["listitem", expect.any(Object)], + ["log", expect.any(Object)], + ["main", expect.any(Object)], + ["marquee", expect.any(Object)], + ["mark", expect.any(Object)], + ["math", expect.any(Object)], + ["menu", expect.any(Object)], + ["menubar", expect.any(Object)], + ["menuitem", expect.any(Object)], + ["menuitemcheckbox", expect.any(Object)], + ["menuitemradio", expect.any(Object)], + ["meter", expect.any(Object)], + ["navigation", expect.any(Object)], + ["none", expect.any(Object)], + ["note", expect.any(Object)], + ["option", expect.any(Object)], + ["paragraph", expect.any(Object)], + ["presentation", expect.any(Object)], + ["progressbar", expect.any(Object)], + ["radio", expect.any(Object)], + ["radiogroup", expect.any(Object)], + ["range", expect.any(Object)], + ["region", expect.any(Object)], + ["roletype", expect.any(Object)], + ["row", expect.any(Object)], + ["rowgroup", expect.any(Object)], + ["rowheader", expect.any(Object)], + ["scrollbar", expect.any(Object)], + ["search", expect.any(Object)], + ["searchbox", expect.any(Object)], + ["section", expect.any(Object)], + ["sectionhead", expect.any(Object)], + ["select", expect.any(Object)], + ["separator", expect.any(Object)], + ["slider", expect.any(Object)], + ["spinbutton", expect.any(Object)], + ["status", expect.any(Object)], + ["strong", expect.any(Object)], + ["structure", expect.any(Object)], + ["subscript", expect.any(Object)], + ["superscript", expect.any(Object)], + ["switch", expect.any(Object)], + ["tab", expect.any(Object)], + ["table", expect.any(Object)], + ["tablist", expect.any(Object)], + ["tabpanel", expect.any(Object)], + ["term", expect.any(Object)], + ["textbox", expect.any(Object)], + ["time", expect.any(Object)], + ["timer", expect.any(Object)], + ["toolbar", expect.any(Object)], + ["tooltip", expect.any(Object)], + ["tree", expect.any(Object)], + ["treegrid", expect.any(Object)], + ["treeitem", expect.any(Object)], + ["widget", expect.any(Object)], + ["window", expect.any(Object)], + ["doc-abstract", expect.any(Object)], + ["doc-acknowledgments", expect.any(Object)], + ["doc-afterword", expect.any(Object)], + ["doc-appendix", expect.any(Object)], + ["doc-backlink", expect.any(Object)], + ["doc-biblioentry", expect.any(Object)], + ["doc-bibliography", expect.any(Object)], + ["doc-biblioref", expect.any(Object)], + ["doc-chapter", expect.any(Object)], + ["doc-colophon", expect.any(Object)], + ["doc-conclusion", expect.any(Object)], + ["doc-cover", expect.any(Object)], + ["doc-credit", expect.any(Object)], + ["doc-credits", expect.any(Object)], + ["doc-dedication", expect.any(Object)], + ["doc-endnote", expect.any(Object)], + ["doc-endnotes", expect.any(Object)], + ["doc-epigraph", expect.any(Object)], + ["doc-epilogue", expect.any(Object)], + ["doc-errata", expect.any(Object)], + ["doc-example", expect.any(Object)], + ["doc-footnote", expect.any(Object)], + ["doc-foreword", expect.any(Object)], + ["doc-glossary", expect.any(Object)], + ["doc-glossref", expect.any(Object)], + ["doc-index", expect.any(Object)], + ["doc-introduction", expect.any(Object)], + ["doc-noteref", expect.any(Object)], + ["doc-notice", expect.any(Object)], + ["doc-pagebreak", expect.any(Object)], + ["doc-pagelist", expect.any(Object)], + ["doc-part", expect.any(Object)], + ["doc-preface", expect.any(Object)], + ["doc-prologue", expect.any(Object)], + ["doc-pullquote", expect.any(Object)], + ["doc-qna", expect.any(Object)], + ["doc-subtitle", expect.any(Object)], + ["doc-tip", expect.any(Object)], + ["doc-toc", expect.any(Object)], + ["graphics-document", expect.any(Object)], + ["graphics-object", expect.any(Object)], + ["graphics-symbol", expect.any(Object)], +]; + describe('rolesMap API', function () { - it('entries', function () { - expect(rolesMap.entries()).toEqual( - expect.arrayContaining( - [ - ["command", expect.any(Object)], - ["composite", expect.any(Object)], - ["input", expect.any(Object)], - ["landmark", expect.any(Object)], - ["range", expect.any(Object)], - ["roletype", expect.any(Object)], - ["section", expect.any(Object)], - ["sectionhead", expect.any(Object)], - ["select", expect.any(Object)], - ["structure", expect.any(Object)], - ["widget", expect.any(Object)], - ["window", expect.any(Object)], - ["alert", expect.any(Object)], - ["alertdialog", expect.any(Object)], - ["application", expect.any(Object)], - ["article", expect.any(Object)], - ["banner", expect.any(Object)], - ["blockquote", expect.any(Object)], - ["button", expect.any(Object)], - ["caption", expect.any(Object)], - ["cell", expect.any(Object)], - ["checkbox", expect.any(Object)], - ["code", expect.any(Object)], - ["columnheader", expect.any(Object)], - ["combobox", expect.any(Object)], - ["complementary", expect.any(Object)], - ["contentinfo", expect.any(Object)], - ["definition", expect.any(Object)], - ["deletion", expect.any(Object)], - ["dialog", expect.any(Object)], - ["directory", expect.any(Object)], - ["document", expect.any(Object)], - ["emphasis", expect.any(Object)], - ["feed", expect.any(Object)], - ["figure", expect.any(Object)], - ["form", expect.any(Object)], - ["generic", expect.any(Object)], - ["grid", expect.any(Object)], - ["gridcell", expect.any(Object)], - ["group", expect.any(Object)], - ["heading", expect.any(Object)], - ["img", expect.any(Object)], - ["insertion", expect.any(Object)], - ["link", expect.any(Object)], - ["list", expect.any(Object)], - ["listbox", expect.any(Object)], - ["listitem", expect.any(Object)], - ["log", expect.any(Object)], - ["main", expect.any(Object)], - ["marquee", expect.any(Object)], - ["math", expect.any(Object)], - ["menu", expect.any(Object)], - ["menubar", expect.any(Object)], - ["menuitem", expect.any(Object)], - ["menuitemcheckbox", expect.any(Object)], - ["menuitemradio", expect.any(Object)], - ["meter", expect.any(Object)], - ["navigation", expect.any(Object)], - ["none", expect.any(Object)], - ["note", expect.any(Object)], - ["option", expect.any(Object)], - ["paragraph", expect.any(Object)], - ["presentation", expect.any(Object)], - ["progressbar", expect.any(Object)], - ["radio", expect.any(Object)], - ["radiogroup", expect.any(Object)], - ["region", expect.any(Object)], - ["row", expect.any(Object)], - ["rowgroup", expect.any(Object)], - ["rowheader", expect.any(Object)], - ["scrollbar", expect.any(Object)], - ["search", expect.any(Object)], - ["searchbox", expect.any(Object)], - ["separator", expect.any(Object)], - ["slider", expect.any(Object)], - ["spinbutton", expect.any(Object)], - ["status", expect.any(Object)], - ["strong", expect.any(Object)], - ["subscript", expect.any(Object)], - ["superscript", expect.any(Object)], - ["switch", expect.any(Object)], - ["tab", expect.any(Object)], - ["table", expect.any(Object)], - ["tablist", expect.any(Object)], - ["tabpanel", expect.any(Object)], - ["term", expect.any(Object)], - ["textbox", expect.any(Object)], - ["time", expect.any(Object)], - ["timer", expect.any(Object)], - ["toolbar", expect.any(Object)], - ["tooltip", expect.any(Object)], - ["tree", expect.any(Object)], - ["treegrid", expect.any(Object)], - ["treeitem", expect.any(Object)], - ["doc-abstract", expect.any(Object)], - ["doc-acknowledgments", expect.any(Object)], - ["doc-afterword", expect.any(Object)], - ["doc-appendix", expect.any(Object)], - ["doc-backlink", expect.any(Object)], - ["doc-biblioentry", expect.any(Object)], - ["doc-bibliography", expect.any(Object)], - ["doc-biblioref", expect.any(Object)], - ["doc-chapter", expect.any(Object)], - ["doc-colophon", expect.any(Object)], - ["doc-conclusion", expect.any(Object)], - ["doc-cover", expect.any(Object)], - ["doc-credit", expect.any(Object)], - ["doc-credits", expect.any(Object)], - ["doc-dedication", expect.any(Object)], - ["doc-endnote", expect.any(Object)], - ["doc-endnotes", expect.any(Object)], - ["doc-epigraph", expect.any(Object)], - ["doc-epilogue", expect.any(Object)], - ["doc-errata", expect.any(Object)], - ["doc-example", expect.any(Object)], - ["doc-footnote", expect.any(Object)], - ["doc-foreword", expect.any(Object)], - ["doc-glossary", expect.any(Object)], - ["doc-glossref", expect.any(Object)], - ["doc-index", expect.any(Object)], - ["doc-introduction", expect.any(Object)], - ["doc-noteref", expect.any(Object)], - ["doc-notice", expect.any(Object)], - ["doc-pagebreak", expect.any(Object)], - ["doc-pagelist", expect.any(Object)], - ["doc-part", expect.any(Object)], - ["doc-preface", expect.any(Object)], - ["doc-prologue", expect.any(Object)], - ["doc-pullquote", expect.any(Object)], - ["doc-qna", expect.any(Object)], - ["doc-subtitle", expect.any(Object)], - ["doc-tip", expect.any(Object)], - ["doc-toc", expect.any(Object)] - ] - ) - ); - expect([...rolesMap.entries()]).toEqual( - expect.arrayContaining( - [ - ["command", expect.any(Object)], - ["composite", expect.any(Object)], - ["input", expect.any(Object)], - ["landmark", expect.any(Object)], - ["range", expect.any(Object)], - ["roletype", expect.any(Object)], - ["section", expect.any(Object)], - ["sectionhead", expect.any(Object)], - ["select", expect.any(Object)], - ["structure", expect.any(Object)], - ["widget", expect.any(Object)], - ["window", expect.any(Object)], - ["alert", expect.any(Object)], - ["alertdialog", expect.any(Object)], - ["application", expect.any(Object)], - ["article", expect.any(Object)], - ["banner", expect.any(Object)], - ["blockquote", expect.any(Object)], - ["button", expect.any(Object)], - ["caption", expect.any(Object)], - ["cell", expect.any(Object)], - ["checkbox", expect.any(Object)], - ["code", expect.any(Object)], - ["columnheader", expect.any(Object)], - ["combobox", expect.any(Object)], - ["complementary", expect.any(Object)], - ["contentinfo", expect.any(Object)], - ["definition", expect.any(Object)], - ["deletion", expect.any(Object)], - ["dialog", expect.any(Object)], - ["directory", expect.any(Object)], - ["document", expect.any(Object)], - ["emphasis", expect.any(Object)], - ["feed", expect.any(Object)], - ["figure", expect.any(Object)], - ["form", expect.any(Object)], - ["generic", expect.any(Object)], - ["grid", expect.any(Object)], - ["gridcell", expect.any(Object)], - ["group", expect.any(Object)], - ["heading", expect.any(Object)], - ["img", expect.any(Object)], - ["insertion", expect.any(Object)], - ["link", expect.any(Object)], - ["list", expect.any(Object)], - ["listbox", expect.any(Object)], - ["listitem", expect.any(Object)], - ["log", expect.any(Object)], - ["main", expect.any(Object)], - ["marquee", expect.any(Object)], - ["math", expect.any(Object)], - ["menu", expect.any(Object)], - ["menubar", expect.any(Object)], - ["menuitem", expect.any(Object)], - ["menuitemcheckbox", expect.any(Object)], - ["menuitemradio", expect.any(Object)], - ["meter", expect.any(Object)], - ["navigation", expect.any(Object)], - ["none", expect.any(Object)], - ["note", expect.any(Object)], - ["option", expect.any(Object)], - ["paragraph", expect.any(Object)], - ["presentation", expect.any(Object)], - ["progressbar", expect.any(Object)], - ["radio", expect.any(Object)], - ["radiogroup", expect.any(Object)], - ["region", expect.any(Object)], - ["row", expect.any(Object)], - ["rowgroup", expect.any(Object)], - ["rowheader", expect.any(Object)], - ["scrollbar", expect.any(Object)], - ["search", expect.any(Object)], - ["searchbox", expect.any(Object)], - ["separator", expect.any(Object)], - ["slider", expect.any(Object)], - ["spinbutton", expect.any(Object)], - ["status", expect.any(Object)], - ["strong", expect.any(Object)], - ["subscript", expect.any(Object)], - ["superscript", expect.any(Object)], - ["switch", expect.any(Object)], - ["tab", expect.any(Object)], - ["table", expect.any(Object)], - ["tablist", expect.any(Object)], - ["tabpanel", expect.any(Object)], - ["term", expect.any(Object)], - ["textbox", expect.any(Object)], - ["time", expect.any(Object)], - ["timer", expect.any(Object)], - ["toolbar", expect.any(Object)], - ["tooltip", expect.any(Object)], - ["tree", expect.any(Object)], - ["treegrid", expect.any(Object)], - ["treeitem", expect.any(Object)], - ["doc-abstract", expect.any(Object)], - ["doc-acknowledgments", expect.any(Object)], - ["doc-afterword", expect.any(Object)], - ["doc-appendix", expect.any(Object)], - ["doc-backlink", expect.any(Object)], - ["doc-biblioentry", expect.any(Object)], - ["doc-bibliography", expect.any(Object)], - ["doc-biblioref", expect.any(Object)], - ["doc-chapter", expect.any(Object)], - ["doc-colophon", expect.any(Object)], - ["doc-conclusion", expect.any(Object)], - ["doc-cover", expect.any(Object)], - ["doc-credit", expect.any(Object)], - ["doc-credits", expect.any(Object)], - ["doc-dedication", expect.any(Object)], - ["doc-endnote", expect.any(Object)], - ["doc-endnotes", expect.any(Object)], - ["doc-epigraph", expect.any(Object)], - ["doc-epilogue", expect.any(Object)], - ["doc-errata", expect.any(Object)], - ["doc-example", expect.any(Object)], - ["doc-footnote", expect.any(Object)], - ["doc-foreword", expect.any(Object)], - ["doc-glossary", expect.any(Object)], - ["doc-glossref", expect.any(Object)], - ["doc-index", expect.any(Object)], - ["doc-introduction", expect.any(Object)], - ["doc-noteref", expect.any(Object)], - ["doc-notice", expect.any(Object)], - ["doc-pagebreak", expect.any(Object)], - ["doc-pagelist", expect.any(Object)], - ["doc-part", expect.any(Object)], - ["doc-preface", expect.any(Object)], - ["doc-prologue", expect.any(Object)], - ["doc-pullquote", expect.any(Object)], - ["doc-qna", expect.any(Object)], - ["doc-subtitle", expect.any(Object)], - ["doc-tip", expect.any(Object)], - ["doc-toc", expect.any(Object)] - ] - ) - ); + describe('entries()', function () { + test.each(rolesMap.entries())(`Testing role: '%s' with definition %o`, (role, definition) => { + expect(entriesList).toEqual( + expect.arrayContaining([[role, definition]]), + ); + }); + test.each([...rolesMap.entries()])(`Testing role: '%s'`, (role, definition) => { + expect(entriesList).toEqual( + expect.arrayContaining([[role, definition]]), + ); + }); }); - it('forEach', function () { + describe('forEach()', function () { const output = []; let context; rolesMap.forEach((value, key, map) => { @@ -292,576 +164,50 @@ describe('rolesMap API', function () { context = map; } }); - expect(output).toEqual( - expect.arrayContaining( - [ - ["command", expect.any(Object)], - ["composite", expect.any(Object)], - ["input", expect.any(Object)], - ["landmark", expect.any(Object)], - ["range", expect.any(Object)], - ["roletype", expect.any(Object)], - ["section", expect.any(Object)], - ["sectionhead", expect.any(Object)], - ["select", expect.any(Object)], - ["structure", expect.any(Object)], - ["widget", expect.any(Object)], - ["window", expect.any(Object)], - ["alert", expect.any(Object)], - ["alertdialog", expect.any(Object)], - ["application", expect.any(Object)], - ["article", expect.any(Object)], - ["banner", expect.any(Object)], - ["blockquote", expect.any(Object)], - ["button", expect.any(Object)], - ["caption", expect.any(Object)], - ["cell", expect.any(Object)], - ["checkbox", expect.any(Object)], - ["code", expect.any(Object)], - ["columnheader", expect.any(Object)], - ["combobox", expect.any(Object)], - ["complementary", expect.any(Object)], - ["contentinfo", expect.any(Object)], - ["definition", expect.any(Object)], - ["deletion", expect.any(Object)], - ["dialog", expect.any(Object)], - ["directory", expect.any(Object)], - ["document", expect.any(Object)], - ["emphasis", expect.any(Object)], - ["feed", expect.any(Object)], - ["figure", expect.any(Object)], - ["form", expect.any(Object)], - ["generic", expect.any(Object)], - ["grid", expect.any(Object)], - ["gridcell", expect.any(Object)], - ["group", expect.any(Object)], - ["heading", expect.any(Object)], - ["img", expect.any(Object)], - ["insertion", expect.any(Object)], - ["link", expect.any(Object)], - ["list", expect.any(Object)], - ["listbox", expect.any(Object)], - ["listitem", expect.any(Object)], - ["log", expect.any(Object)], - ["main", expect.any(Object)], - ["marquee", expect.any(Object)], - ["math", expect.any(Object)], - ["menu", expect.any(Object)], - ["menubar", expect.any(Object)], - ["menuitem", expect.any(Object)], - ["menuitemcheckbox", expect.any(Object)], - ["menuitemradio", expect.any(Object)], - ["meter", expect.any(Object)], - ["navigation", expect.any(Object)], - ["none", expect.any(Object)], - ["note", expect.any(Object)], - ["option", expect.any(Object)], - ["paragraph", expect.any(Object)], - ["presentation", expect.any(Object)], - ["progressbar", expect.any(Object)], - ["radio", expect.any(Object)], - ["radiogroup", expect.any(Object)], - ["region", expect.any(Object)], - ["row", expect.any(Object)], - ["rowgroup", expect.any(Object)], - ["rowheader", expect.any(Object)], - ["scrollbar", expect.any(Object)], - ["search", expect.any(Object)], - ["searchbox", expect.any(Object)], - ["separator", expect.any(Object)], - ["slider", expect.any(Object)], - ["spinbutton", expect.any(Object)], - ["status", expect.any(Object)], - ["strong", expect.any(Object)], - ["subscript", expect.any(Object)], - ["superscript", expect.any(Object)], - ["switch", expect.any(Object)], - ["tab", expect.any(Object)], - ["table", expect.any(Object)], - ["tablist", expect.any(Object)], - ["tabpanel", expect.any(Object)], - ["term", expect.any(Object)], - ["textbox", expect.any(Object)], - ["time", expect.any(Object)], - ["timer", expect.any(Object)], - ["toolbar", expect.any(Object)], - ["tooltip", expect.any(Object)], - ["tree", expect.any(Object)], - ["treegrid", expect.any(Object)], - ["treeitem", expect.any(Object)], - ["doc-abstract", expect.any(Object)], - ["doc-acknowledgments", expect.any(Object)], - ["doc-afterword", expect.any(Object)], - ["doc-appendix", expect.any(Object)], - ["doc-backlink", expect.any(Object)], - ["doc-biblioentry", expect.any(Object)], - ["doc-bibliography", expect.any(Object)], - ["doc-biblioref", expect.any(Object)], - ["doc-chapter", expect.any(Object)], - ["doc-colophon", expect.any(Object)], - ["doc-conclusion", expect.any(Object)], - ["doc-cover", expect.any(Object)], - ["doc-credit", expect.any(Object)], - ["doc-credits", expect.any(Object)], - ["doc-dedication", expect.any(Object)], - ["doc-endnote", expect.any(Object)], - ["doc-endnotes", expect.any(Object)], - ["doc-epigraph", expect.any(Object)], - ["doc-epilogue", expect.any(Object)], - ["doc-errata", expect.any(Object)], - ["doc-example", expect.any(Object)], - ["doc-footnote", expect.any(Object)], - ["doc-foreword", expect.any(Object)], - ["doc-glossary", expect.any(Object)], - ["doc-glossref", expect.any(Object)], - ["doc-index", expect.any(Object)], - ["doc-introduction", expect.any(Object)], - ["doc-noteref", expect.any(Object)], - ["doc-notice", expect.any(Object)], - ["doc-pagebreak", expect.any(Object)], - ["doc-pagelist", expect.any(Object)], - ["doc-part", expect.any(Object)], - ["doc-preface", expect.any(Object)], - ["doc-prologue", expect.any(Object)], - ["doc-pullquote", expect.any(Object)], - ["doc-qna", expect.any(Object)], - ["doc-subtitle", expect.any(Object)], - ["doc-tip", expect.any(Object)], - ["doc-toc", expect.any(Object)] - ] - ) - ); - expect(context).toEqual( - expect.arrayContaining( - [ - ["command", expect.any(Object)], - ["composite", expect.any(Object)], - ["input", expect.any(Object)], - ["landmark", expect.any(Object)], - ["range", expect.any(Object)], - ["roletype", expect.any(Object)], - ["section", expect.any(Object)], - ["sectionhead", expect.any(Object)], - ["select", expect.any(Object)], - ["structure", expect.any(Object)], - ["widget", expect.any(Object)], - ["window", expect.any(Object)], - ["alert", expect.any(Object)], - ["alertdialog", expect.any(Object)], - ["application", expect.any(Object)], - ["article", expect.any(Object)], - ["banner", expect.any(Object)], - ["blockquote", expect.any(Object)], - ["button", expect.any(Object)], - ["caption", expect.any(Object)], - ["cell", expect.any(Object)], - ["checkbox", expect.any(Object)], - ["code", expect.any(Object)], - ["columnheader", expect.any(Object)], - ["combobox", expect.any(Object)], - ["complementary", expect.any(Object)], - ["contentinfo", expect.any(Object)], - ["definition", expect.any(Object)], - ["deletion", expect.any(Object)], - ["dialog", expect.any(Object)], - ["directory", expect.any(Object)], - ["document", expect.any(Object)], - ["emphasis", expect.any(Object)], - ["feed", expect.any(Object)], - ["figure", expect.any(Object)], - ["form", expect.any(Object)], - ["generic", expect.any(Object)], - ["grid", expect.any(Object)], - ["gridcell", expect.any(Object)], - ["group", expect.any(Object)], - ["heading", expect.any(Object)], - ["img", expect.any(Object)], - ["insertion", expect.any(Object)], - ["link", expect.any(Object)], - ["list", expect.any(Object)], - ["listbox", expect.any(Object)], - ["listitem", expect.any(Object)], - ["log", expect.any(Object)], - ["main", expect.any(Object)], - ["marquee", expect.any(Object)], - ["math", expect.any(Object)], - ["menu", expect.any(Object)], - ["menubar", expect.any(Object)], - ["menuitem", expect.any(Object)], - ["menuitemcheckbox", expect.any(Object)], - ["menuitemradio", expect.any(Object)], - ["meter", expect.any(Object)], - ["navigation", expect.any(Object)], - ["none", expect.any(Object)], - ["note", expect.any(Object)], - ["option", expect.any(Object)], - ["paragraph", expect.any(Object)], - ["presentation", expect.any(Object)], - ["progressbar", expect.any(Object)], - ["radio", expect.any(Object)], - ["radiogroup", expect.any(Object)], - ["region", expect.any(Object)], - ["row", expect.any(Object)], - ["rowgroup", expect.any(Object)], - ["rowheader", expect.any(Object)], - ["scrollbar", expect.any(Object)], - ["search", expect.any(Object)], - ["searchbox", expect.any(Object)], - ["separator", expect.any(Object)], - ["slider", expect.any(Object)], - ["spinbutton", expect.any(Object)], - ["status", expect.any(Object)], - ["strong", expect.any(Object)], - ["subscript", expect.any(Object)], - ["superscript", expect.any(Object)], - ["switch", expect.any(Object)], - ["tab", expect.any(Object)], - ["table", expect.any(Object)], - ["tablist", expect.any(Object)], - ["tabpanel", expect.any(Object)], - ["term", expect.any(Object)], - ["textbox", expect.any(Object)], - ["time", expect.any(Object)], - ["timer", expect.any(Object)], - ["toolbar", expect.any(Object)], - ["tooltip", expect.any(Object)], - ["tree", expect.any(Object)], - ["treegrid", expect.any(Object)], - ["treeitem", expect.any(Object)], - ["doc-abstract", expect.any(Object)], - ["doc-acknowledgments", expect.any(Object)], - ["doc-afterword", expect.any(Object)], - ["doc-appendix", expect.any(Object)], - ["doc-backlink", expect.any(Object)], - ["doc-biblioentry", expect.any(Object)], - ["doc-bibliography", expect.any(Object)], - ["doc-biblioref", expect.any(Object)], - ["doc-chapter", expect.any(Object)], - ["doc-colophon", expect.any(Object)], - ["doc-conclusion", expect.any(Object)], - ["doc-cover", expect.any(Object)], - ["doc-credit", expect.any(Object)], - ["doc-credits", expect.any(Object)], - ["doc-dedication", expect.any(Object)], - ["doc-endnote", expect.any(Object)], - ["doc-endnotes", expect.any(Object)], - ["doc-epigraph", expect.any(Object)], - ["doc-epilogue", expect.any(Object)], - ["doc-errata", expect.any(Object)], - ["doc-example", expect.any(Object)], - ["doc-footnote", expect.any(Object)], - ["doc-foreword", expect.any(Object)], - ["doc-glossary", expect.any(Object)], - ["doc-glossref", expect.any(Object)], - ["doc-index", expect.any(Object)], - ["doc-introduction", expect.any(Object)], - ["doc-noteref", expect.any(Object)], - ["doc-notice", expect.any(Object)], - ["doc-pagebreak", expect.any(Object)], - ["doc-pagelist", expect.any(Object)], - ["doc-part", expect.any(Object)], - ["doc-preface", expect.any(Object)], - ["doc-prologue", expect.any(Object)], - ["doc-pullquote", expect.any(Object)], - ["doc-qna", expect.any(Object)], - ["doc-subtitle", expect.any(Object)], - ["doc-tip", expect.any(Object)], - ["doc-toc", expect.any(Object)] - ] - ) - ); + test.each(output)(`Testing role: '%s'`, (role, definition) => { + expect(entriesList).toEqual( + expect.arrayContaining([[role, definition]]), + ); + }); + test.each(context)(`Testing role: '%s'`, (role, definition) => { + expect(entriesList).toEqual( + expect.arrayContaining([[role, definition]]), + ); + }); }); - it('get', function () { + it('get()', function () { expect(rolesMap.get('roletype')).toBeDefined(); expect(rolesMap.get('fake role')).toBeUndefined(); }); - it('has', function () { + it('has()', function () { expect(rolesMap.has('roletype')).toEqual(true); expect(rolesMap.has('fake role')).toEqual(false); }); - it('keys', function () { - expect(rolesMap.keys()).toEqual( - expect.arrayContaining( - [ - "command", - "composite", - "input", - "landmark", - "range", - "roletype", - "section", - "sectionhead", - "select", - "structure", - "widget", - "window", - "alert", - "alertdialog", - "application", - "article", - "banner", - "blockquote", - "button", - "caption", - "cell", - "checkbox", - "code", - "columnheader", - "combobox", - "complementary", - "contentinfo", - "definition", - "deletion", - "dialog", - "directory", - "document", - "emphasis", - "feed", - "figure", - "form", - "generic", - "grid", - "gridcell", - "group", - "heading", - "img", - "insertion", - "link", - "list", - "listbox", - "listitem", - "log", - "main", - "marquee", - "math", - "menu", - "menubar", - "menuitem", - "menuitemcheckbox", - "menuitemradio", - "meter", - "navigation", - "none", - "note", - "option", - "paragraph", - "presentation", - "progressbar", - "radio", - "radiogroup", - "region", - "row", - "rowgroup", - "rowheader", - "scrollbar", - "search", - "searchbox", - "separator", - "slider", - "spinbutton", - "status", - "strong", - "subscript", - "superscript", - "switch", - "tab", - "table", - "tablist", - "tabpanel", - "term", - "textbox", - "time", - "timer", - "toolbar", - "tooltip", - "tree", - "treegrid", - "treeitem", - "doc-abstract", - "doc-acknowledgments", - "doc-afterword", - "doc-appendix", - "doc-backlink", - "doc-biblioentry", - "doc-bibliography", - "doc-biblioref", - "doc-chapter", - "doc-colophon", - "doc-conclusion", - "doc-cover", - "doc-credit", - "doc-credits", - "doc-dedication", - "doc-endnote", - "doc-endnotes", - "doc-epigraph", - "doc-epilogue", - "doc-errata", - "doc-example", - "doc-footnote", - "doc-foreword", - "doc-glossary", - "doc-glossref", - "doc-index", - "doc-introduction", - "doc-noteref", - "doc-notice", - "doc-pagebreak", - "doc-pagelist", - "doc-part", - "doc-preface", - "doc-prologue", - "doc-pullquote", - "doc-qna", - "doc-subtitle", - "doc-tip", - "doc-toc" - ] - ) - ); - expect([...rolesMap.keys()]).toEqual( - expect.arrayContaining( - [ - "command", - "composite", - "input", - "landmark", - "range", - "roletype", - "section", - "sectionhead", - "select", - "structure", - "widget", - "window", - "alert", - "alertdialog", - "application", - "article", - "banner", - "blockquote", - "button", - "caption", - "cell", - "checkbox", - "code", - "columnheader", - "combobox", - "complementary", - "contentinfo", - "definition", - "deletion", - "dialog", - "directory", - "document", - "emphasis", - "feed", - "figure", - "form", - "generic", - "grid", - "gridcell", - "group", - "heading", - "img", - "insertion", - "link", - "list", - "listbox", - "listitem", - "log", - "main", - "marquee", - "math", - "menu", - "menubar", - "menuitem", - "menuitemcheckbox", - "menuitemradio", - "meter", - "navigation", - "none", - "note", - "option", - "paragraph", - "presentation", - "progressbar", - "radio", - "radiogroup", - "region", - "row", - "rowgroup", - "rowheader", - "scrollbar", - "search", - "searchbox", - "separator", - "slider", - "spinbutton", - "status", - "strong", - "subscript", - "superscript", - "switch", - "tab", - "table", - "tablist", - "tabpanel", - "term", - "textbox", - "time", - "timer", - "toolbar", - "tooltip", - "tree", - "treegrid", - "treeitem", - "doc-abstract", - "doc-acknowledgments", - "doc-afterword", - "doc-appendix", - "doc-backlink", - "doc-biblioentry", - "doc-bibliography", - "doc-biblioref", - "doc-chapter", - "doc-colophon", - "doc-conclusion", - "doc-cover", - "doc-credit", - "doc-credits", - "doc-dedication", - "doc-endnote", - "doc-endnotes", - "doc-epigraph", - "doc-epilogue", - "doc-errata", - "doc-example", - "doc-footnote", - "doc-foreword", - "doc-glossary", - "doc-glossref", - "doc-index", - "doc-introduction", - "doc-noteref", - "doc-notice", - "doc-pagebreak", - "doc-pagelist", - "doc-part", - "doc-preface", - "doc-prologue", - "doc-pullquote", - "doc-qna", - "doc-subtitle", - "doc-tip", - "doc-toc" - ] - ) - ); + describe('keys()', function () { + const entriesKeys = entriesList.map(entry => entry[0]); + test.each(rolesMap.keys())('Testing key: %o', (key) => { + expect(entriesKeys).toEqual( + expect.arrayContaining([key]), + ); + }); + test.each([...rolesMap.keys()])('Testing key: %o', (key) => { + expect(entriesKeys).toEqual( + expect.arrayContaining([key]), + ); + }); }); - it('values', function () { - expect(rolesMap.values().length).toEqual(136); - expect([...rolesMap.values()].length).toEqual(136); + describe('values()', function () { + const entriesValues = entriesList.map(entry => entry[1]); + test.each(rolesMap.values().map(value => [value]))('Testing value: %o', (value) => { + expect(entriesValues).toEqual( + expect.arrayContaining([value]), + ); + }); + test.each([...rolesMap.values()].map(value => [value]))('Testing value: %o', (value) => { + expect(entriesValues).toEqual( + expect.arrayContaining([value]), + ); + }); }); }); @@ -870,298 +216,26 @@ describe('rolesMap', function () { it('should have an iterator defined', function () { expect(rolesMap[Symbol.iterator]).not.toBeUndefined(); }); - it('should support the spread operator', function () { - expect([...rolesMap].length).toEqual(136); - expect([...rolesMap]).toEqual( - expect.arrayContaining( - [ - ["command", expect.any(Object)], - ["composite", expect.any(Object)], - ["input", expect.any(Object)], - ["landmark", expect.any(Object)], - ["range", expect.any(Object)], - ["roletype", expect.any(Object)], - ["section", expect.any(Object)], - ["sectionhead", expect.any(Object)], - ["select", expect.any(Object)], - ["structure", expect.any(Object)], - ["widget", expect.any(Object)], - ["window", expect.any(Object)], - ["alert", expect.any(Object)], - ["alertdialog", expect.any(Object)], - ["application", expect.any(Object)], - ["article", expect.any(Object)], - ["banner", expect.any(Object)], - ["blockquote", expect.any(Object)], - ["button", expect.any(Object)], - ["caption", expect.any(Object)], - ["cell", expect.any(Object)], - ["checkbox", expect.any(Object)], - ["code", expect.any(Object)], - ["columnheader", expect.any(Object)], - ["combobox", expect.any(Object)], - ["complementary", expect.any(Object)], - ["contentinfo", expect.any(Object)], - ["definition", expect.any(Object)], - ["deletion", expect.any(Object)], - ["dialog", expect.any(Object)], - ["directory", expect.any(Object)], - ["document", expect.any(Object)], - ["emphasis", expect.any(Object)], - ["feed", expect.any(Object)], - ["figure", expect.any(Object)], - ["form", expect.any(Object)], - ["generic", expect.any(Object)], - ["grid", expect.any(Object)], - ["gridcell", expect.any(Object)], - ["group", expect.any(Object)], - ["heading", expect.any(Object)], - ["img", expect.any(Object)], - ["insertion", expect.any(Object)], - ["link", expect.any(Object)], - ["list", expect.any(Object)], - ["listbox", expect.any(Object)], - ["listitem", expect.any(Object)], - ["log", expect.any(Object)], - ["main", expect.any(Object)], - ["marquee", expect.any(Object)], - ["math", expect.any(Object)], - ["menu", expect.any(Object)], - ["menubar", expect.any(Object)], - ["menuitem", expect.any(Object)], - ["menuitemcheckbox", expect.any(Object)], - ["menuitemradio", expect.any(Object)], - ["meter", expect.any(Object)], - ["navigation", expect.any(Object)], - ["none", expect.any(Object)], - ["note", expect.any(Object)], - ["option", expect.any(Object)], - ["paragraph", expect.any(Object)], - ["presentation", expect.any(Object)], - ["progressbar", expect.any(Object)], - ["radio", expect.any(Object)], - ["radiogroup", expect.any(Object)], - ["region", expect.any(Object)], - ["row", expect.any(Object)], - ["rowgroup", expect.any(Object)], - ["rowheader", expect.any(Object)], - ["scrollbar", expect.any(Object)], - ["search", expect.any(Object)], - ["searchbox", expect.any(Object)], - ["separator", expect.any(Object)], - ["slider", expect.any(Object)], - ["spinbutton", expect.any(Object)], - ["status", expect.any(Object)], - ["strong", expect.any(Object)], - ["subscript", expect.any(Object)], - ["superscript", expect.any(Object)], - ["switch", expect.any(Object)], - ["tab", expect.any(Object)], - ["table", expect.any(Object)], - ["tablist", expect.any(Object)], - ["tabpanel", expect.any(Object)], - ["term", expect.any(Object)], - ["textbox", expect.any(Object)], - ["time", expect.any(Object)], - ["timer", expect.any(Object)], - ["toolbar", expect.any(Object)], - ["tooltip", expect.any(Object)], - ["tree", expect.any(Object)], - ["treegrid", expect.any(Object)], - ["treeitem", expect.any(Object)], - ["doc-abstract", expect.any(Object)], - ["doc-acknowledgments", expect.any(Object)], - ["doc-afterword", expect.any(Object)], - ["doc-appendix", expect.any(Object)], - ["doc-backlink", expect.any(Object)], - ["doc-biblioentry", expect.any(Object)], - ["doc-bibliography", expect.any(Object)], - ["doc-biblioref", expect.any(Object)], - ["doc-chapter", expect.any(Object)], - ["doc-colophon", expect.any(Object)], - ["doc-conclusion", expect.any(Object)], - ["doc-cover", expect.any(Object)], - ["doc-credit", expect.any(Object)], - ["doc-credits", expect.any(Object)], - ["doc-dedication", expect.any(Object)], - ["doc-endnote", expect.any(Object)], - ["doc-endnotes", expect.any(Object)], - ["doc-epigraph", expect.any(Object)], - ["doc-epilogue", expect.any(Object)], - ["doc-errata", expect.any(Object)], - ["doc-example", expect.any(Object)], - ["doc-footnote", expect.any(Object)], - ["doc-foreword", expect.any(Object)], - ["doc-glossary", expect.any(Object)], - ["doc-glossref", expect.any(Object)], - ["doc-index", expect.any(Object)], - ["doc-introduction", expect.any(Object)], - ["doc-noteref", expect.any(Object)], - ["doc-notice", expect.any(Object)], - ["doc-pagebreak", expect.any(Object)], - ["doc-pagelist", expect.any(Object)], - ["doc-part", expect.any(Object)], - ["doc-preface", expect.any(Object)], - ["doc-prologue", expect.any(Object)], - ["doc-pullquote", expect.any(Object)], - ["doc-qna", expect.any(Object)], - ["doc-subtitle", expect.any(Object)], - ["doc-tip", expect.any(Object)], - ["doc-toc", expect.any(Object)], - ["graphics-document", expect.any(Object)], - ["graphics-object", expect.any(Object)], - ["graphics-symbol", expect.any(Object)], - ] - ) - ); + describe('spread operator', function () { + it('should have a specific length', function () { + expect([...rolesMap].length).toEqual(137); + }); + test.each([...rolesMap])('Testing element: %o', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); - it('should support the for..of pattern', function () { + describe('for..of pattern', function () { const output = []; for (const [key, value] of rolesMap) { output.push([key, value]); } - expect(output).toEqual( - expect.arrayContaining( - [ - ["command", expect.any(Object)], - ["composite", expect.any(Object)], - ["input", expect.any(Object)], - ["landmark", expect.any(Object)], - ["range", expect.any(Object)], - ["roletype", expect.any(Object)], - ["section", expect.any(Object)], - ["sectionhead", expect.any(Object)], - ["select", expect.any(Object)], - ["structure", expect.any(Object)], - ["widget", expect.any(Object)], - ["window", expect.any(Object)], - ["alert", expect.any(Object)], - ["alertdialog", expect.any(Object)], - ["application", expect.any(Object)], - ["article", expect.any(Object)], - ["banner", expect.any(Object)], - ["blockquote", expect.any(Object)], - ["button", expect.any(Object)], - ["caption", expect.any(Object)], - ["cell", expect.any(Object)], - ["checkbox", expect.any(Object)], - ["code", expect.any(Object)], - ["columnheader", expect.any(Object)], - ["combobox", expect.any(Object)], - ["complementary", expect.any(Object)], - ["contentinfo", expect.any(Object)], - ["definition", expect.any(Object)], - ["deletion", expect.any(Object)], - ["dialog", expect.any(Object)], - ["directory", expect.any(Object)], - ["document", expect.any(Object)], - ["emphasis", expect.any(Object)], - ["feed", expect.any(Object)], - ["figure", expect.any(Object)], - ["form", expect.any(Object)], - ["generic", expect.any(Object)], - ["grid", expect.any(Object)], - ["gridcell", expect.any(Object)], - ["group", expect.any(Object)], - ["heading", expect.any(Object)], - ["img", expect.any(Object)], - ["insertion", expect.any(Object)], - ["link", expect.any(Object)], - ["list", expect.any(Object)], - ["listbox", expect.any(Object)], - ["listitem", expect.any(Object)], - ["log", expect.any(Object)], - ["main", expect.any(Object)], - ["marquee", expect.any(Object)], - ["math", expect.any(Object)], - ["menu", expect.any(Object)], - ["menubar", expect.any(Object)], - ["menuitem", expect.any(Object)], - ["menuitemcheckbox", expect.any(Object)], - ["menuitemradio", expect.any(Object)], - ["meter", expect.any(Object)], - ["navigation", expect.any(Object)], - ["none", expect.any(Object)], - ["note", expect.any(Object)], - ["option", expect.any(Object)], - ["paragraph", expect.any(Object)], - ["presentation", expect.any(Object)], - ["progressbar", expect.any(Object)], - ["radio", expect.any(Object)], - ["radiogroup", expect.any(Object)], - ["region", expect.any(Object)], - ["row", expect.any(Object)], - ["rowgroup", expect.any(Object)], - ["rowheader", expect.any(Object)], - ["scrollbar", expect.any(Object)], - ["search", expect.any(Object)], - ["searchbox", expect.any(Object)], - ["separator", expect.any(Object)], - ["slider", expect.any(Object)], - ["spinbutton", expect.any(Object)], - ["status", expect.any(Object)], - ["strong", expect.any(Object)], - ["subscript", expect.any(Object)], - ["superscript", expect.any(Object)], - ["switch", expect.any(Object)], - ["tab", expect.any(Object)], - ["table", expect.any(Object)], - ["tablist", expect.any(Object)], - ["tabpanel", expect.any(Object)], - ["term", expect.any(Object)], - ["textbox", expect.any(Object)], - ["time", expect.any(Object)], - ["timer", expect.any(Object)], - ["toolbar", expect.any(Object)], - ["tooltip", expect.any(Object)], - ["tree", expect.any(Object)], - ["treegrid", expect.any(Object)], - ["treeitem", expect.any(Object)], - ["doc-abstract", expect.any(Object)], - ["doc-acknowledgments", expect.any(Object)], - ["doc-afterword", expect.any(Object)], - ["doc-appendix", expect.any(Object)], - ["doc-backlink", expect.any(Object)], - ["doc-biblioentry", expect.any(Object)], - ["doc-bibliography", expect.any(Object)], - ["doc-biblioref", expect.any(Object)], - ["doc-chapter", expect.any(Object)], - ["doc-colophon", expect.any(Object)], - ["doc-conclusion", expect.any(Object)], - ["doc-cover", expect.any(Object)], - ["doc-credit", expect.any(Object)], - ["doc-credits", expect.any(Object)], - ["doc-dedication", expect.any(Object)], - ["doc-endnote", expect.any(Object)], - ["doc-endnotes", expect.any(Object)], - ["doc-epigraph", expect.any(Object)], - ["doc-epilogue", expect.any(Object)], - ["doc-errata", expect.any(Object)], - ["doc-example", expect.any(Object)], - ["doc-footnote", expect.any(Object)], - ["doc-foreword", expect.any(Object)], - ["doc-glossary", expect.any(Object)], - ["doc-glossref", expect.any(Object)], - ["doc-index", expect.any(Object)], - ["doc-introduction", expect.any(Object)], - ["doc-noteref", expect.any(Object)], - ["doc-notice", expect.any(Object)], - ["doc-pagebreak", expect.any(Object)], - ["doc-pagelist", expect.any(Object)], - ["doc-part", expect.any(Object)], - ["doc-preface", expect.any(Object)], - ["doc-prologue", expect.any(Object)], - ["doc-pullquote", expect.any(Object)], - ["doc-qna", expect.any(Object)], - ["doc-subtitle", expect.any(Object)], - ["doc-tip", expect.any(Object)], - ["doc-toc", expect.any(Object)], - ["graphics-document", expect.any(Object)], - ["graphics-object", expect.any(Object)], - ["graphics-symbol", expect.any(Object)], - ] - ) - ); + test.each(output)('Testing element: %o', (obj, roles) => { + expect(entriesList).toEqual( + expect.arrayContaining([[obj, roles]]), + ); + }); }); }); describe('content', function () { diff --git a/flow/aria.js b/flow/aria.js index 8af5d127..ba1f22ab 100644 --- a/flow/aria.js +++ b/flow/aria.js @@ -70,6 +70,7 @@ type ARIADocumentStructureRole = | 'insertion' | 'list' | 'listitem' + | 'mark' | 'math' | 'meter' | 'none' @@ -166,7 +167,9 @@ type ARIARole = | ARIALandmarkRole | ARIALiveRegionRole | ARIAWindowRole - | ARIAUncategorizedRole; + | ARIAUncategorizedRole + | ARIADPubRole + | ARIAGraphicsRole; type ARIARoleDefinitionKey = ARIAAbstractRole @@ -174,20 +177,30 @@ type ARIARoleDefinitionKey = | ARIADPubRole | ARIAGraphicsRole; -type ARIARoleDefinition = { +type ARIANameFromSources = + 'author' + | 'contents' + | 'prohibited'; + +type ARIARoleDefinition = {| /* Abstract roles may not be used in HTML. */ abstract: boolean, + accessibleNameRequired: boolean, /* The concepts in related domains that inform behavior mappings. */ baseConcepts: Array, /* Child presentational roles strip child nodes of roles and flatten the * content to text. */ childrenPresentational: boolean, + nameFrom?: Array, /* aria-* properties and states disallowed on this role. */ prohibitedProps: $Keys[], /* aria-* properties and states allowed on this role. */ props: ARIAPropertyMap, /* The concepts in related domains that inform behavior mappings. */ relatedConcepts: Array, + requireContextRole?: Array, + requiredContextRole?: Array, + requiredOwnedElements?: Array>, /* aria-* properties and states required on this role. */ requiredProps: ARIAPropertyMap, /* An array or super class "stacks." Each stack contains a LIFO list of @@ -195,7 +208,7 @@ type ARIARoleDefinition = { * role. Roles may have more than one inheritance chain, which is why * this property is an array of arrays and not a single array. */ superClass: Array>, -}; +|}; type RoleDefinitionTuple = [ARIARoleDefinitionKey, ARIARoleDefinition]; type RoleDefinitions = Array; @@ -215,12 +228,15 @@ type ARIAProperty = 'aria-activedescendant' | 'aria-atomic' | 'aria-autocomplete' + | 'aria-braillelabel' + | 'aria-brailleroledescription' | 'aria-colcount' | 'aria-colindex' | 'aria-colspan' | 'aria-controls' | 'aria-current' | 'aria-describedby' + | 'aria-description' | 'aria-details' | 'aria-dropeffect' | 'aria-errormessage' @@ -255,29 +271,30 @@ type ARIAProperty = // {| [AriaProperty]?: mixed |} type ARIAPropertyMap = {| - 'aria-busy'?: mixed, - 'aria-checked'?: mixed, - 'aria-disabled'?: mixed, - 'aria-expanded'?: mixed, - 'aria-grabbed'?: mixed, - 'aria-hidden'?: mixed, - 'aria-invalid'?: mixed, - 'aria-pressed'?: mixed, - 'aria-selected'?: mixed, 'aria-activedescendant'?: mixed, 'aria-atomic'?: mixed, 'aria-autocomplete'?: mixed, + 'aria-braillelabel'?: mixed, + 'aria-brailleroledescription'?: mixed, + 'aria-busy'?: mixed, + 'aria-checked'?: mixed, 'aria-colcount'?: mixed, 'aria-colindex'?: mixed, 'aria-colspan'?: mixed, 'aria-controls'?: mixed, 'aria-current'?: ?ARIAPropertyCurrent, 'aria-describedby'?: mixed, + 'aria-description'?: mixed, 'aria-details'?: mixed, + 'aria-disabled'?: mixed, 'aria-dropeffect'?: mixed, 'aria-errormessage'?: mixed, + 'aria-expanded'?: mixed, 'aria-flowto'?: mixed, + 'aria-grabbed'?: mixed, 'aria-haspopup'?: mixed, + 'aria-hidden'?: mixed, + 'aria-invalid'?: mixed, 'aria-keyshortcuts'?: mixed, 'aria-label'?: mixed, 'aria-labelledby'?: mixed, @@ -290,6 +307,7 @@ type ARIAPropertyMap = {| 'aria-owns'?: mixed, 'aria-placeholder'?: mixed, 'aria-posinset'?: mixed, + 'aria-pressed'?: mixed, 'aria-readonly'?: mixed, 'aria-relevant'?: mixed, 'aria-required'?: mixed, @@ -297,6 +315,7 @@ type ARIAPropertyMap = {| 'aria-rowcount'?: mixed, 'aria-rowindex'?: mixed, 'aria-rowspan'?: mixed, + 'aria-selected'?: mixed, 'aria-setsize'?: mixed, 'aria-sort'?: mixed, 'aria-valuemax'?: mixed, @@ -305,7 +324,7 @@ type ARIAPropertyMap = {| 'aria-valuetext'?: mixed, |}; -type ARIAPropertyDefinition = { +type ARIAPropertyDefinition = {| type: 'string' | 'id' | 'idlist' @@ -317,7 +336,7 @@ type ARIAPropertyDefinition = { | 'tristate', values?: Array, allowundefined?: boolean, -}; +|}; type ARIAPropertyCurrent = 'page' @@ -330,31 +349,44 @@ type ARIAPropertyCurrent = | true | false; -type ARIARoleRelation = { +type ARIARoleRelation = {| module?: string, concept?: ARIARoleRelationConcept, -}; +|}; /* The concept in a related domain that informs behavior mappings. * Related domains include: HTML, "Device Independence Delivery Unit", XForms, * and ARIA to name a few. */ -type ARIARoleRelationConcept = { +type ARIARoleRelationConcept = {| name: string, attributes?: Array, // These constraints are drawn from the mapping between ARIA and HTML: // https://www.w3.org/TR/html-aria - constraints?: Array<'direct descendant of document' - | 'direct descendant of ol, ul or menu' + constraints?: Array< + | 'scoped to the body element' + | 'scoped to the main element' + | 'scoped to a sectioning root element other than body' + | 'scoped to a sectioning content element' + | 'direct descendant of document' + | 'direct descendant of ol' + | 'direct descendant of ul' + | 'direct descendant of menu' | 'direct descendant of details element with the open attribute defined' - | 'descendant of table'>, -}; + | 'ancestor table element has table role' + | 'ancestor table element has grid role' + | 'ancestor table element has treegrid role' + | 'the progress bar is determinate' + | 'the datalist selection model allows multiple option elements to be selected at a time' + | 'the aria-controls attribute is set to the same value as the list attribute' + | 'the size attribute value is greater than 1' + | 'the multiple attribute value is greater than 1' + | 'the multiple attribute and the size attribute do not have a value greater than 1' + | 'the list attribute is not set'>, +|}; -type ARIARoleRelationConceptAttribute = { +type ARIARoleRelationConceptAttribute = {| name: string, value?: string | number, // These constraints are drawn from the mapping between ARIA and HTML: // https://www.w3.org/TR/html-aria - constraints?: Array<'undefined' // The attribute does not exist on the node: - | 'set' // The attribute has a value: - | '>1'>, -}; +|}; diff --git a/scripts/roles.json b/scripts/roles.json index 67fb7896..a8503036 100644 --- a/scripts/roles.json +++ b/scripts/roles.json @@ -187,7 +187,7 @@ "relatedConcepts": [ { "concept": { - "constraints": ["direct descendant of document"], + "constraints": ["scoped to the body element"], "name": "header" }, "module": "HTML" @@ -223,7 +223,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "blockquote" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -259,49 +266,6 @@ "aria-roledescription" ], "relatedConcepts": [ - { - "concept": { - "attributes": [ - { - "constraints": ["set"], - "name": "aria-pressed" - }, - { - "name": "type", - "value": "checkbox" - } - ], - "name": "input" - }, - "module": "HTML" - }, - { - "concept": { - "attributes": [ - { - "name": "aria-expanded", - "value": "false" - } - ], - "name": "summary" - }, - "module": "HTML" - }, - { - "concept": { - "attributes": [ - { - "name": "aria-expanded", - "value": "true" - } - ], - "constraints": [ - "direct descendant of details element with the open attribute defined" - ], - "name": "summary" - }, - "module": "HTML" - }, { "concept": { "attributes": [ @@ -391,7 +355,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "caption" + }, + "module": "HTML" + } + ], "requiredContextRole": ["figure", "grid", "table"], "requiredOwnedElements": [], "requiredProps": [], @@ -429,7 +400,9 @@ "relatedConcepts": [ { "concept": { - "constraints": ["descendant of table"], + "constraints": [ + "ancestor table element has table role" + ], "name": "td" }, "module": "HTML" @@ -520,7 +493,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "code" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -566,16 +546,35 @@ ], "relatedConcepts": [ { - "attributes": [ - { - "name": "scope", - "value": "col" - } - ], "concept": { "name": "th" }, "module": "HTML" + }, + { + "concept": { + "attributes": [ + { + "name": "scope", + "value": "col" + } + ], + "name": "th" + }, + "module": "HTML" + }, + { + + "concept": { + "attributes": [ + { + "name": "scope", + "value": "colgroup" + } + ], + "name": "th" + }, + "module": "HTML" } ], "requiredContextRole": ["row"], @@ -622,7 +621,9 @@ "concept": { "attributes": [ { - "constraints": ["set"], + "name": "aria-controls" + }, + { "name": "list" }, { @@ -630,6 +631,9 @@ "value": "email" } ], + "constraints": [ + "the aria-controls attribute is set to the same value as the list attribute" + ], "name": "input" }, "module": "HTML" @@ -638,7 +642,9 @@ "concept": { "attributes": [ { - "constraints": ["set"], + "name": "aria-controls" + }, + { "name": "list" }, { @@ -646,6 +652,9 @@ "value": "search" } ], + "constraints": [ + "the aria-controls attribute is set to the same value as the list attribute" + ], "name": "input" }, "module": "HTML" @@ -654,7 +663,9 @@ "concept": { "attributes": [ { - "constraints": ["set"], + "name": "aria-controls" + }, + { "name": "list" }, { @@ -662,6 +673,9 @@ "value": "tel" } ], + "constraints": [ + "the aria-controls attribute is set to the same value as the list attribute" + ], "name": "input" }, "module": "HTML" @@ -670,7 +684,9 @@ "concept": { "attributes": [ { - "constraints": ["set"], + "name": "aria-controls" + }, + { "name": "list" }, { @@ -678,6 +694,9 @@ "value": "text" } ], + "constraints": [ + "the aria-controls attribute is set to the same value as the list attribute" + ], "name": "input" }, "module": "HTML" @@ -686,7 +705,9 @@ "concept": { "attributes": [ { - "constraints": ["set"], + "name": "aria-controls" + }, + { "name": "list" }, { @@ -694,6 +715,9 @@ "value": "url" } ], + "constraints": [ + "the aria-controls attribute is set to the same value as the list attribute" + ], "name": "input" }, "module": "HTML" @@ -702,7 +726,9 @@ "concept": { "attributes": [ { - "constraints": ["set"], + "name": "aria-controls" + }, + { "name": "list" }, { @@ -710,6 +736,9 @@ "value": "url" } ], + "constraints": [ + "the aria-controls attribute is set to the same value as the list attribute" + ], "name": "input" }, "module": "HTML" @@ -718,29 +747,14 @@ "concept": { "attributes": [ { - "constraints": ["undefined"], "name": "multiple" }, { - "constraints": ["undefined"], "name": "size" } ], - "name": "select" - }, - "module": "HTML" - }, - { - "concept": { - "attributes": [ - { - "constraints": ["undefined"], - "name": "multiple" - }, - { - "name": "size", - "value": 1 - } + "constraints": [ + "the multiple attribute and the size attribute do not have a value greater than 1" ], "name": "select" }, @@ -783,14 +797,7 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [ - { - "concept": { - "name": "menuitem" - }, - "module": "HTML" - } - ], + "relatedConcepts": [], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -827,6 +834,36 @@ "name": "aside" }, "module": "HTML" + }, + { + "concept": { + "attributes": [ + { + "name": "aria-label" + } + ], + "constraints": [ + "scoped to a sectioning content element", + "scoped to a sectioning root element other than body" + ], + "name": "aside" + }, + "module": "HTML" + }, + { + "concept": { + "attributes": [ + { + "name": "aria-labelledby" + } + ], + "constraints": [ + "scoped to a sectioning content element", + "scoped to a sectioning root element other than body" + ], + "name": "aside" + }, + "module": "HTML" } ], "requiredContextRole": [], @@ -895,7 +932,7 @@ "relatedConcepts": [ { "concept": { - "constraints": ["direct descendant of document"], + "constraints": ["scoped to the body element"], "name": "footer" }, "module": "HTML" @@ -967,7 +1004,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "del" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -1223,7 +1267,7 @@ "abstract": false, "accessibleNameRequired": true, "childrenPresentational": false, - "nameFrom": ["author", "content"], + "nameFrom": ["author", "contents"], "prohibitedProps": [], "props": [ "aria-atomic", @@ -2734,7 +2778,7 @@ }, { "concept": { - "name": "body" + "name": "html" }, "module": "HTML" } @@ -2767,7 +2811,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "em" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -2872,7 +2923,6 @@ "concept": { "attributes": [ { - "constraints": ["set"], "name": "aria-label" } ], @@ -2884,7 +2934,6 @@ "concept": { "attributes": [ { - "constraints": ["set"], "name": "aria-labelledby" } ], @@ -2896,7 +2945,6 @@ "concept": { "attributes": [ { - "constraints": ["set"], "name": "name" } ], @@ -2934,97 +2982,210 @@ "aria-roledescription" ], "relatedConcepts": [ + { "concept": { - "name": "span" + "name": "a" }, "module": "HTML" }, { "concept": { - "name": "div" + "name": "area" }, "module": "HTML" - } - ], - "requiredContextRole": [], - "requiredOwnedElements": [], - "requiredProps": [], - "superClass": ["structure"] - }, - "graphics-document": { - "abstract": false, - "accessibleNameRequired": true, - "childrenPresentational": false, - "nameFrom": ["author"], - "prohibitedProps": [], - "props": [ - "aria-atomic", - "aria-busy", - "aria-controls", - "aria-current", - "aria-describedby", - "aria-details", - "aria-disabled", - "aria-dropeffect", - "aria-errormessage", - "aria-expanded", - "aria-flowto", - "aria-grabbed", - "aria-haspopup", - "aria-hidden", - "aria-invalid", - "aria-keyshortcuts", - "aria-label", - "aria-labelledby", - "aria-live", - "aria-owns", - "aria-relevant", - "aria-roledescription" - ], - "relatedConcepts": [ + }, { - "module": "GRAPHICS", "concept": { - "name": "graphics-object" - } + "name": "aside" + }, + "module": "HTML" }, { - "module": "ARIA", "concept": { - "name": "img" - } + "name": "b" + }, + "module": "HTML" }, { - "module": "ARIA", "concept": { - "name": "article" - } - } - ], - "requiredContextRole": [], - "requiredOwnedElements": [], - "requiredProps": [], - "superClass": ["document"] - }, - "graphics-object": { - "abstract": false, - "accessibleNameRequired": false, - "childrenPresentational": false, - "nameFrom": ["author", "contents"], - "prohibitedProps": [], - "props": [ - "aria-activedescendant", - "aria-atomic", - "aria-busy", - "aria-controls", - "aria-current", - "aria-describedby", - "aria-details", - "aria-disabled", - "aria-dropeffect", - "aria-errormessage", - "aria-expanded", + "name": "bdo" + }, + "module": "HTML" + }, + { + "concept": { + "name": "body" + }, + "module": "HTML" + }, + { + "concept": { + "name": "data" + }, + "module": "HTML" + }, + { + "concept": { + "name": "div" + }, + "module": "HTML" + }, + { + "concept": { + "constraints": [ + "scoped to the main element", + "scoped to a sectioning content element", + "scoped to a sectioning root element other than body" + ], + "name": "footer" + }, + "module": "HTML" + }, + { + "concept": { + "constraints": [ + "scoped to the main element", + "scoped to a sectioning content element", + "scoped to a sectioning root element other than body" + ], + "name": "header" + }, + "module": "HTML" + }, + { + "concept": { + "name": "hgroup" + }, + "module": "HTML" + }, + { + "concept": { + "name": "i" + }, + "module": "HTML" + }, + { + "concept": { + "name": "pre" + }, + "module": "HTML" + }, + { + "concept": { + "name": "q" + }, + "module": "HTML" + }, + { + "concept": { + "name": "samp" + }, + "module": "HTML" + }, + { + "concept": { + "name": "section" + }, + "module": "HTML" + }, + { + "concept": { + "name": "small" + }, + "module": "HTML" + }, + { + "concept": { + "name": "span" + }, + "module": "HTML" + }, + { + "concept": { + "name": "u" + }, + "module": "HTML" + } + ], + "requiredContextRole": [], + "requiredOwnedElements": [], + "requiredProps": [], + "superClass": ["structure"] + }, + "graphics-document": { + "abstract": false, + "accessibleNameRequired": true, + "childrenPresentational": false, + "nameFrom": ["author"], + "prohibitedProps": [], + "props": [ + "aria-atomic", + "aria-busy", + "aria-controls", + "aria-current", + "aria-describedby", + "aria-details", + "aria-disabled", + "aria-dropeffect", + "aria-errormessage", + "aria-expanded", + "aria-flowto", + "aria-grabbed", + "aria-haspopup", + "aria-hidden", + "aria-invalid", + "aria-keyshortcuts", + "aria-label", + "aria-labelledby", + "aria-live", + "aria-owns", + "aria-relevant", + "aria-roledescription" + ], + "relatedConcepts": [ + { + "module": "GRAPHICS", + "concept": { + "name": "graphics-object" + } + }, + { + "module": "ARIA", + "concept": { + "name": "img" + } + }, + { + "module": "ARIA", + "concept": { + "name": "article" + } + } + ], + "requiredContextRole": [], + "requiredOwnedElements": [], + "requiredProps": [], + "superClass": ["document"] + }, + "graphics-object": { + "abstract": false, + "accessibleNameRequired": false, + "childrenPresentational": false, + "nameFrom": ["author", "contents"], + "prohibitedProps": [], + "props": [ + "aria-activedescendant", + "aria-atomic", + "aria-busy", + "aria-controls", + "aria-current", + "aria-describedby", + "aria-details", + "aria-disabled", + "aria-dropeffect", + "aria-errormessage", + "aria-expanded", "aria-flowto", "aria-grabbed", "aria-haspopup", @@ -3136,20 +3297,7 @@ "aria-roledescription", "aria-rowcount" ], - "relatedConcepts": [ - { - "concept": { - "attributes": [ - { - "name": "role", - "value": "grid" - } - ], - "name": "table" - }, - "module": "HTML" - } - ], + "relatedConcepts": [], "requiredContextRole": [], "requiredOwnedElements": [["row"], ["row", "rowgroup"]], "requiredProps": [], @@ -3195,11 +3343,8 @@ "relatedConcepts": [ { "concept": { - "attributes": [ - { - "name": "role", - "value": "gridcell" - } + "constraints": [ + "ancestor table element has grid role" ], "name": "td" }, @@ -3256,6 +3401,12 @@ "name": "optgroup" }, "module": "HTML" + }, + { + "concept": { + "name": "address" + }, + "module": "HTML" } ], "requiredContextRole": [], @@ -3360,24 +3511,6 @@ "relatedConcepts": [ { "concept": { - "attributes": [ - { - "constraints": ["set"], - "name": "alt" - } - ], - "name": "img" - }, - "module": "HTML" - }, - { - "concept": { - "attributes": [ - { - "constraints": ["undefined"], - "name": "alt" - } - ], "name": "img" }, "module": "HTML" @@ -3456,7 +3589,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "ins" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -3543,17 +3683,6 @@ "name": "area" }, "module": "HTML" - }, - { - "concept": { - "attributes": [ - { - "name": "href" - } - ], - "name": "link" - }, - "module": "HTML" } ], "requiredContextRole": [], @@ -3650,13 +3779,15 @@ "concept": { "attributes": [ { - "constraints": [">1"], "name": "size" }, { "name": "multiple" } ], + "constraints":[ + "the size attribute value is greater than 1" + ], "name": "select" }, "module": "HTML" @@ -3665,10 +3796,12 @@ "concept": { "attributes": [ { - "constraints": [">1"], "name": "size" } ], + "constraints":[ + "the size attribute value is greater than 1" + ], "name": "select" }, "module": "HTML" @@ -3680,16 +3813,40 @@ "name": "multiple" } ], + "constraints": [ + "the multiple attribute value is greater than 1" + ], "name": "select" }, "module": "HTML" }, { "concept": { + "attributes": [ + { + "name": "aria-multiselectable", + "value": "true" + } + ], + "constraints": [ + "the datalist selection model allows multiple option elements to be selected at a time" + ], "name": "datalist" }, "module": "HTML" }, + { + "concept": { + "name": "datalist", + "attributes": [ + { + "name": "aria-multiselectable", + "value": "false" + } + ] + }, + "module": "HTML" + }, { "concept": { "name": "list" @@ -3739,7 +3896,11 @@ "relatedConcepts": [ { "concept": { - "constraints": ["direct descendant of ol, ul or menu"], + "constraints": [ + "direct descendant of ol", + "direct descendant of ul", + "direct descendant of menu" + ], "name": "li" }, "module": "HTML" @@ -3825,6 +3986,47 @@ "requiredProps": [], "superClass": ["landmark"] }, + "mark": { + "abstract": false, + "accessibleNameRequired": false, + "childrenPresentational": false, + "nameFrom": ["prohibited"], + "prohibitedProps": [], + "props": [ + "aria-atomic", + "aria-braillelabel", + "aria-brailleroledescription", + "aria-busy", + "aria-controls", + "aria-current", + "aria-describedby", + "aria-description", + "aria-details", + "aria-dropeffect", + "aria-flowto", + "aria-grabbed", + "aria-hidden", + "aria-keyshortcuts", + "aria-label", + "aria-labelledby", + "aria-live", + "aria-owns", + "aria-relevant", + "aria-roledescription" + ], + "relatedConcepts": [ + { + "concept": { + "name": "mark" + }, + "module": "HTML" + } + ], + "requiredContextRole": [], + "requiredOwnedElements": [], + "requiredProps": [], + "superClass": ["section"] + }, "marquee": { "abstract": false, "accessibleNameRequired": true, @@ -4045,18 +4247,6 @@ }, "module": "JAPI" }, - { - "concept": { - "name": "listitem" - }, - "module": "ARIA" - }, - { - "concept": { - "name": "menuitem" - }, - "module": "HTML" - }, { "concept": { "name": "option" @@ -4194,7 +4384,14 @@ ["aria-valuemax", "100"], ["aria-valuemin", "0"] ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "meter" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": ["aria-valuenow"], @@ -4360,7 +4557,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "p" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -4389,7 +4593,20 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "attributes": [ + { + "name": "alt", + "value": "" + } + ], + "name": "img" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -4431,6 +4648,27 @@ }, "module": "HTML" }, + { + "concept": { + "attributes": [ + { + "name": "aria-valuemax" + }, + { + "name": "aria-valuemin", + "value": 0 + }, + { + "name": "aria-valuenow" + } + ], + "constraints": [ + "the progress bar is determinate" + ], + "name": "progress" + }, + "module": "HTML" + }, { "concept": { "name": "status" @@ -4600,7 +4838,6 @@ "concept": { "attributes": [ { - "constraints": ["set"], "name": "aria-label" } ], @@ -4612,7 +4849,6 @@ "concept": { "attributes": [ { - "constraints": ["set"], "name": "aria-labelledby" } ], @@ -4624,12 +4860,6 @@ "concept": { "name": "Device Independence Glossart perceivable unit" } - }, - { - "concept": { - "name": "frame" - }, - "module": "HTML" } ], "requiredContextRole": [], @@ -4663,12 +4893,6 @@ "aria-roledescription" ], "relatedConcepts": [ - { - "concept": { - "name": "rel" - }, - "module": "HTML" - }, { "concept": { "name": "role" @@ -4966,7 +5190,6 @@ "concept": { "attributes": [ { - "constraints": ["undefined"], "name": "list" }, { @@ -4974,6 +5197,9 @@ "value": "search" } ], + "constraints":[ + "the list attribute is not set" + ], "name": "input" }, "module": "HTML" @@ -5010,6 +5236,28 @@ "aria-roledescription" ], "relatedConcepts": [ + { + "concept": { + "attributes": [ + { + "name": "aria-label" + } + ], + "name": "section" + }, + "module": "HTML" + }, + { + "concept": { + "attributes": [ + { + "name": "aria-labelledby" + } + ], + "name": "section" + }, + "module": "HTML" + }, { "concept": { "name": "frontmatter" @@ -5312,7 +5560,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "strong" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -5372,7 +5627,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "sub" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -5401,7 +5663,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "sup" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -5442,9 +5711,12 @@ "relatedConcepts": [ { "concept": { + "attributes":[{ + "name": "aria-checked" + }], "name": "button" }, - "module": "ARIA" + "module": "HTML" } ], "requiredContextRole": [], @@ -5685,15 +5957,8 @@ "relatedConcepts": [ { "concept": { - "attributes": [ - { - "constraints": ["undefined"], - "name": "type" - }, - { - "constraints": ["undefined"], - "name": "list" - } + "constraints":[ + "the list attribute is not set" ], "name": "input" }, @@ -5702,15 +5967,14 @@ { "concept": { "attributes": [ - { - "constraints": ["undefined"], - "name": "list" - }, { "name": "type", "value": "email" } ], + "constraints":[ + "the list attribute is not set" + ], "name": "input" }, "module": "HTML" @@ -5718,15 +5982,14 @@ { "concept": { "attributes": [ - { - "constraints": ["undefined"], - "name": "list" - }, { "name": "type", "value": "tel" } ], + "constraints":[ + "the list attribute is not set" + ], "name": "input" }, "module": "HTML" @@ -5734,15 +5997,14 @@ { "concept": { "attributes": [ - { - "constraints": ["undefined"], - "name": "list" - }, { "name": "type", "value": "text" } ], + "constraints":[ + "the list attribute is not set" + ], "name": "input" }, "module": "HTML" @@ -5750,15 +6012,14 @@ { "concept": { "attributes": [ - { - "constraints": ["undefined"], - "name": "list" - }, { "name": "type", "value": "url" } ], + "constraints":[ + "the list attribute is not set" + ], "name": "input" }, "module": "HTML" @@ -5806,7 +6067,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "time" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], diff --git a/src/ariaPropsMap.js b/src/ariaPropsMap.js index df0a340a..a3703777 100644 --- a/src/ariaPropsMap.js +++ b/src/ariaPropsMap.js @@ -23,6 +23,12 @@ const properties: ARIAPropertyDefinitions = [ 'none' ] }], + ['aria-braillelabel', { + 'type': 'string' + }], + ['aria-brailleroledescription', { + 'type': 'string' + }], ['aria-busy', { 'type': 'boolean' }], @@ -56,6 +62,9 @@ const properties: ARIAPropertyDefinitions = [ ['aria-describedby', { 'type': 'idlist' }], + ['aria-description', { + 'type': 'string' + }], ['aria-details', { 'type': 'id' }], diff --git a/src/elementRoleMap.js b/src/elementRoleMap.js index e9ab0482..35a2233b 100644 --- a/src/elementRoleMap.js +++ b/src/elementRoleMap.js @@ -24,8 +24,7 @@ for (let i = 0; i < keys.length; i++) { if (relation.module === 'HTML') { const concept = relation.concept; if (concept) { - const conceptStr = JSON.stringify(concept); - const elementRoleRelation: ?ElementARIARoleRelationTuple = elementRoles.find(relation => JSON.stringify(relation[0]) === conceptStr); + const elementRoleRelation: ?ElementARIARoleRelationTuple = elementRoles.find(relation => deepEqual(relation, concept)); let roles: RoleSet; if (elementRoleRelation) { @@ -67,9 +66,9 @@ const elementRoleMap: TAriaQueryMap< } }, get: function (key: ARIARoleRelationConcept): ?RoleSet { - const item = elementRoles.find( - tuple => deepEqual(key, tuple[0]), - ); + const item = elementRoles.find(tuple => ( + key.name === tuple[0].name && deepEqual(key.attributes, tuple[0].attributes) + )); return item && item[1]; }, has: function (key: ARIARoleRelationConcept): boolean { diff --git a/src/etc/roles/abstract/commandRole.js b/src/etc/roles/abstract/commandRole.js index 2a18e86e..c28da220 100644 --- a/src/etc/roles/abstract/commandRole.js +++ b/src/etc/roles/abstract/commandRole.js @@ -11,14 +11,7 @@ const commandRole: ARIARoleDefinition = { ], prohibitedProps: [], props: {}, - relatedConcepts: [ - { - concept: { - name: 'menuitem', - }, - module: 'HTML', - }, - ], + relatedConcepts: [], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [], diff --git a/src/etc/roles/abstract/roletypeRole.js b/src/etc/roles/abstract/roletypeRole.js index 38c8db38..7d66c14c 100644 --- a/src/etc/roles/abstract/roletypeRole.js +++ b/src/etc/roles/abstract/roletypeRole.js @@ -28,12 +28,6 @@ const roletypeRole: ARIARoleDefinition = { 'aria-roledescription': null, }, relatedConcepts: [ - { - concept: { - name: 'rel', - }, - module: 'HTML', - }, { concept: { name: 'role', diff --git a/src/etc/roles/abstract/sectionRole.js b/src/etc/roles/abstract/sectionRole.js index eafda12e..b8595bdd 100644 --- a/src/etc/roles/abstract/sectionRole.js +++ b/src/etc/roles/abstract/sectionRole.js @@ -10,6 +10,28 @@ const sectionRole: ARIARoleDefinition = { prohibitedProps: [], props: {}, relatedConcepts: [ + { + concept: { + attributes: [ + { + name: 'aria-label', + }, + ], + name: 'section', + }, + module: 'HTML', + }, + { + concept: { + attributes: [ + { + name: 'aria-labelledby', + }, + ], + name: 'section', + }, + module: 'HTML', + }, { concept: { name: 'frontmatter', diff --git a/src/etc/roles/ariaLiteralRoles.js b/src/etc/roles/ariaLiteralRoles.js index 82d20092..bcc06ec3 100644 --- a/src/etc/roles/ariaLiteralRoles.js +++ b/src/etc/roles/ariaLiteralRoles.js @@ -38,6 +38,7 @@ import listboxRole from './literal/listboxRole'; import listitemRole from './literal/listitemRole'; import logRole from './literal/logRole'; import mainRole from './literal/mainRole'; +import markRole from './literal/markRole'; import marqueeRole from './literal/marqueeRole'; import mathRole from './literal/mathRole'; import menuRole from './literal/menuRole'; @@ -122,6 +123,7 @@ const ariaLiteralRoles: RoleDefinitions = [ ['listitem', listitemRole], ['log', logRole], ['main', mainRole], + ['mark', markRole], ['marquee', marqueeRole], ['math', mathRole], ['menu', menuRole], diff --git a/src/etc/roles/dpub/docBacklinkRole.js b/src/etc/roles/dpub/docBacklinkRole.js index 11fe5119..130efc87 100644 --- a/src/etc/roles/dpub/docBacklinkRole.js +++ b/src/etc/roles/dpub/docBacklinkRole.js @@ -8,7 +8,7 @@ const docBacklinkRole: ARIARoleDefinition = { childrenPresentational: false, nameFrom: [ 'author', - 'content', + 'contents', ], prohibitedProps: [], props: { diff --git a/src/etc/roles/literal/bannerRole.js b/src/etc/roles/literal/bannerRole.js index 34d20b9b..5da7b5c6 100644 --- a/src/etc/roles/literal/bannerRole.js +++ b/src/etc/roles/literal/bannerRole.js @@ -15,7 +15,7 @@ const bannerRole: ARIARoleDefinition = { { concept: { constraints: [ - 'direct descendant of document', + 'scoped to the body element', ], name: 'header', }, diff --git a/src/etc/roles/literal/blockquoteRole.js b/src/etc/roles/literal/blockquoteRole.js index 71c511af..72b9b5c5 100644 --- a/src/etc/roles/literal/blockquoteRole.js +++ b/src/etc/roles/literal/blockquoteRole.js @@ -11,7 +11,14 @@ const blockquoteRole: ARIARoleDefinition = { ], prohibitedProps: [], props: {}, - relatedConcepts: [], + relatedConcepts: [ + { + concept: { + name: 'blockquote', + }, + module: 'HTML', + }, + ], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [], diff --git a/src/etc/roles/literal/buttonRole.js b/src/etc/roles/literal/buttonRole.js index ffda5d1a..122126f4 100644 --- a/src/etc/roles/literal/buttonRole.js +++ b/src/etc/roles/literal/buttonRole.js @@ -18,51 +18,6 @@ const buttonRole: ARIARoleDefinition = { 'aria-pressed': null, }, relatedConcepts: [ - { - concept: { - attributes: [ - { - constraints: [ - 'set', - ], - name: 'aria-pressed', - }, - { - name: 'type', - value: 'checkbox', - }, - ], - name: 'input', - }, - module: 'HTML', - }, - { - concept: { - attributes: [ - { - name: 'aria-expanded', - value: 'false', - }, - ], - name: 'summary', - }, - module: 'HTML', - }, - { - concept: { - attributes: [ - { - name: 'aria-expanded', - value: 'true', - }, - ], - constraints: [ - 'direct descendant of details element with the open attribute defined', - ], - name: 'summary', - }, - module: 'HTML', - }, { concept: { attributes: [ diff --git a/src/etc/roles/literal/captionRole.js b/src/etc/roles/literal/captionRole.js index e8638ceb..55a1ff2d 100644 --- a/src/etc/roles/literal/captionRole.js +++ b/src/etc/roles/literal/captionRole.js @@ -14,7 +14,14 @@ const captionRole: ARIARoleDefinition = { 'aria-labelledby', ], props: {}, - relatedConcepts: [], + relatedConcepts: [ + { + concept: { + name: 'caption', + }, + module: 'HTML', + }, + ], requireContextRole: [ 'figure', 'grid', diff --git a/src/etc/roles/literal/cellRole.js b/src/etc/roles/literal/cellRole.js index d9417026..9eb06fe5 100644 --- a/src/etc/roles/literal/cellRole.js +++ b/src/etc/roles/literal/cellRole.js @@ -21,7 +21,7 @@ const cellRole: ARIARoleDefinition = { { concept: { constraints: [ - 'descendant of table', + 'ancestor table element has table role', ], name: 'td', }, diff --git a/src/etc/roles/literal/codeRole.js b/src/etc/roles/literal/codeRole.js index 26f58684..7b80b701 100644 --- a/src/etc/roles/literal/codeRole.js +++ b/src/etc/roles/literal/codeRole.js @@ -14,7 +14,14 @@ const codeRole: ARIARoleDefinition = { 'aria-labelledby', ], props: {}, - relatedConcepts: [], + relatedConcepts: [ + { + concept: { + name: 'code', + }, + module: 'HTML', + }, + ], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [], diff --git a/src/etc/roles/literal/columnheaderRole.js b/src/etc/roles/literal/columnheaderRole.js index 0380a054..b86cd8e4 100644 --- a/src/etc/roles/literal/columnheaderRole.js +++ b/src/etc/roles/literal/columnheaderRole.js @@ -16,17 +16,35 @@ const columnheaderRole: ARIARoleDefinition = { }, relatedConcepts: [ { - attributes: [ - { - name: 'scope', - value: 'col', - }, - ], concept: { name: 'th', }, module: 'HTML', }, + { + concept: { + attributes: [ + { + name: 'scope', + value: 'col', + }, + ], + name: 'th', + }, + module: 'HTML', + }, + { + concept: { + attributes: [ + { + name: 'scope', + value: 'colgroup', + }, + ], + name: 'th', + }, + module: 'HTML', + }, ], requireContextRole: [ 'row', diff --git a/src/etc/roles/literal/comboboxRole.js b/src/etc/roles/literal/comboboxRole.js index c1fc7bfc..3479daa2 100644 --- a/src/etc/roles/literal/comboboxRole.js +++ b/src/etc/roles/literal/comboboxRole.js @@ -25,9 +25,9 @@ const comboboxRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'set', - ], + name: 'aria-controls', + }, + { name: 'list', }, { @@ -35,6 +35,9 @@ const comboboxRole: ARIARoleDefinition = { value: 'email', }, ], + constraints: [ + 'the aria-controls attribute is set to the same value as the list attribute', + ], name: 'input', }, module: 'HTML', @@ -43,9 +46,9 @@ const comboboxRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'set', - ], + name: 'aria-controls', + }, + { name: 'list', }, { @@ -53,6 +56,9 @@ const comboboxRole: ARIARoleDefinition = { value: 'search', }, ], + constraints: [ + 'the aria-controls attribute is set to the same value as the list attribute', + ], name: 'input', }, module: 'HTML', @@ -61,9 +67,9 @@ const comboboxRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'set', - ], + name: 'aria-controls', + }, + { name: 'list', }, { @@ -71,6 +77,9 @@ const comboboxRole: ARIARoleDefinition = { value: 'tel', }, ], + constraints: [ + 'the aria-controls attribute is set to the same value as the list attribute', + ], name: 'input', }, module: 'HTML', @@ -79,9 +88,9 @@ const comboboxRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'set', - ], + name: 'aria-controls', + }, + { name: 'list', }, { @@ -89,6 +98,9 @@ const comboboxRole: ARIARoleDefinition = { value: 'text', }, ], + constraints: [ + 'the aria-controls attribute is set to the same value as the list attribute', + ], name: 'input', }, module: 'HTML', @@ -97,9 +109,9 @@ const comboboxRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'set', - ], + name: 'aria-controls', + }, + { name: 'list', }, { @@ -107,6 +119,9 @@ const comboboxRole: ARIARoleDefinition = { value: 'url', }, ], + constraints: [ + 'the aria-controls attribute is set to the same value as the list attribute', + ], name: 'input', }, module: 'HTML', @@ -115,9 +130,9 @@ const comboboxRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'set', - ], + name: 'aria-controls', + }, + { name: 'list', }, { @@ -125,6 +140,9 @@ const comboboxRole: ARIARoleDefinition = { value: 'url', }, ], + constraints: [ + 'the aria-controls attribute is set to the same value as the list attribute', + ], name: 'input', }, module: 'HTML', @@ -133,35 +151,14 @@ const comboboxRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'undefined', - ], name: 'multiple', }, { - constraints: [ - 'undefined', - ], name: 'size', }, ], - name: 'select', - }, - module: 'HTML', - }, - { - concept: { - attributes: [ - { - constraints: [ - 'undefined', - ], - name: 'multiple', - }, - { - name: 'size', - value: 1, - }, + constraints: [ + 'the multiple attribute and the size attribute do not have a value greater than 1', ], name: 'select', }, diff --git a/src/etc/roles/literal/complementaryRole.js b/src/etc/roles/literal/complementaryRole.js index 28626b4e..bfe27553 100644 --- a/src/etc/roles/literal/complementaryRole.js +++ b/src/etc/roles/literal/complementaryRole.js @@ -18,6 +18,36 @@ const complementaryRole: ARIARoleDefinition = { }, module: 'HTML', }, + { + concept: { + attributes: [ + { + name: 'aria-label', + }, + ], + constraints: [ + 'scoped to a sectioning content element', + 'scoped to a sectioning root element other than body', + ], + name: 'aside', + }, + module: 'HTML', + }, + { + concept: { + attributes: [ + { + name: 'aria-labelledby', + }, + ], + constraints: [ + 'scoped to a sectioning content element', + 'scoped to a sectioning root element other than body', + ], + name: 'aside', + }, + module: 'HTML', + }, ], requireContextRole: [], requiredContextRole: [], diff --git a/src/etc/roles/literal/contentinfoRole.js b/src/etc/roles/literal/contentinfoRole.js index 773e3a26..503fd643 100644 --- a/src/etc/roles/literal/contentinfoRole.js +++ b/src/etc/roles/literal/contentinfoRole.js @@ -15,7 +15,7 @@ const contentinfoRole: ARIARoleDefinition = { { concept: { constraints: [ - 'direct descendant of document', + 'scoped to the body element', ], name: 'footer', }, diff --git a/src/etc/roles/literal/deletionRole.js b/src/etc/roles/literal/deletionRole.js index df654fde..4ca5f533 100644 --- a/src/etc/roles/literal/deletionRole.js +++ b/src/etc/roles/literal/deletionRole.js @@ -14,7 +14,14 @@ const deletionRole: ARIARoleDefinition = { 'aria-labelledby', ], props: {}, - relatedConcepts: [], + relatedConcepts: [ + { + concept: { + name: 'del', + }, + module: 'HTML', + }, + ], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [], diff --git a/src/etc/roles/literal/documentRole.js b/src/etc/roles/literal/documentRole.js index edaf45b2..a4e5f555 100644 --- a/src/etc/roles/literal/documentRole.js +++ b/src/etc/roles/literal/documentRole.js @@ -19,7 +19,7 @@ const documentRole: ARIARoleDefinition = { }, { concept: { - name: 'body', + name: 'html', }, module: 'HTML', }, diff --git a/src/etc/roles/literal/emphasisRole.js b/src/etc/roles/literal/emphasisRole.js index 039bc55e..a1e1dcb9 100644 --- a/src/etc/roles/literal/emphasisRole.js +++ b/src/etc/roles/literal/emphasisRole.js @@ -14,7 +14,14 @@ const emphasisRole: ARIARoleDefinition = { 'aria-labelledby', ], props: {}, - relatedConcepts: [], + relatedConcepts: [ + { + concept: { + name: 'em', + }, + module: 'HTML', + }, + ], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [], diff --git a/src/etc/roles/literal/formRole.js b/src/etc/roles/literal/formRole.js index 7e51354d..0cb7f954 100644 --- a/src/etc/roles/literal/formRole.js +++ b/src/etc/roles/literal/formRole.js @@ -16,9 +16,6 @@ const formRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'set', - ], name: 'aria-label', }, ], @@ -30,9 +27,6 @@ const formRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'set', - ], name: 'aria-labelledby', }, ], @@ -44,9 +38,6 @@ const formRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'set', - ], name: 'name', }, ], diff --git a/src/etc/roles/literal/genericRole.js b/src/etc/roles/literal/genericRole.js index 70e302e7..e929a413 100644 --- a/src/etc/roles/literal/genericRole.js +++ b/src/etc/roles/literal/genericRole.js @@ -17,7 +17,43 @@ const genericRole: ARIARoleDefinition = { relatedConcepts: [ { concept: { - name: 'span', + name: 'a', + }, + module: 'HTML', + }, + { + concept: { + name: 'area', + }, + module: 'HTML', + }, + { + concept: { + name: 'aside', + }, + module: 'HTML', + }, + { + concept: { + name: 'b', + }, + module: 'HTML', + }, + { + concept: { + name: 'bdo', + }, + module: 'HTML', + }, + { + concept: { + name: 'body', + }, + module: 'HTML', + }, + { + concept: { + name: 'data', }, module: 'HTML', }, @@ -27,6 +63,82 @@ const genericRole: ARIARoleDefinition = { }, module: 'HTML', }, + { + concept: { + constraints: [ + 'scoped to the main element', + 'scoped to a sectioning content element', + 'scoped to a sectioning root element other than body', + ], + name: 'footer', + }, + module: 'HTML', + }, + { + concept: { + constraints: [ + 'scoped to the main element', + 'scoped to a sectioning content element', + 'scoped to a sectioning root element other than body', + ], + name: 'header', + }, + module: 'HTML', + }, + { + concept: { + name: 'hgroup', + }, + module: 'HTML', + }, + { + concept: { + name: 'i', + }, + module: 'HTML', + }, + { + concept: { + name: 'pre', + }, + module: 'HTML', + }, + { + concept: { + name: 'q', + }, + module: 'HTML', + }, + { + concept: { + name: 'samp', + }, + module: 'HTML', + }, + { + concept: { + name: 'section', + }, + module: 'HTML', + }, + { + concept: { + name: 'small', + }, + module: 'HTML', + }, + { + concept: { + name: 'span', + }, + module: 'HTML', + }, + { + concept: { + name: 'u', + }, + module: 'HTML', + }, ], requireContextRole: [], requiredContextRole: [], diff --git a/src/etc/roles/literal/gridRole.js b/src/etc/roles/literal/gridRole.js index 20e002f0..bb7b43b4 100644 --- a/src/etc/roles/literal/gridRole.js +++ b/src/etc/roles/literal/gridRole.js @@ -14,20 +14,7 @@ const gridRole: ARIARoleDefinition = { 'aria-multiselectable': null, 'aria-readonly': null, }, - relatedConcepts: [ - { - concept: { - attributes: [ - { - name: 'role', - value: 'grid', - }, - ], - name: 'table', - }, - module: 'HTML', - }, - ], + relatedConcepts: [], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [ diff --git a/src/etc/roles/literal/gridcellRole.js b/src/etc/roles/literal/gridcellRole.js index 77c5684a..d08e1d5e 100644 --- a/src/etc/roles/literal/gridcellRole.js +++ b/src/etc/roles/literal/gridcellRole.js @@ -24,11 +24,8 @@ const gridcellRole: ARIARoleDefinition = { relatedConcepts: [ { concept: { - attributes: [ - { - name: 'role', - value: 'gridcell', - }, + constraints: [ + 'ancestor table element has grid role', ], name: 'td', }, diff --git a/src/etc/roles/literal/groupRole.js b/src/etc/roles/literal/groupRole.js index febec1da..4ab57c01 100644 --- a/src/etc/roles/literal/groupRole.js +++ b/src/etc/roles/literal/groupRole.js @@ -33,6 +33,12 @@ const groupRole: ARIARoleDefinition = { }, module: 'HTML', }, + { + concept: { + name: 'address', + }, + module: 'HTML', + }, ], requireContextRole: [], requiredContextRole: [], diff --git a/src/etc/roles/literal/imgRole.js b/src/etc/roles/literal/imgRole.js index 2e00746d..f784d89b 100644 --- a/src/etc/roles/literal/imgRole.js +++ b/src/etc/roles/literal/imgRole.js @@ -14,28 +14,6 @@ const imgRole: ARIARoleDefinition = { relatedConcepts: [ { concept: { - attributes: [ - { - constraints: [ - 'set', - ], - name: 'alt', - }, - ], - name: 'img', - }, - module: 'HTML', - }, - { - concept: { - attributes: [ - { - constraints: [ - 'undefined', - ], - name: 'alt', - }, - ], name: 'img', }, module: 'HTML', diff --git a/src/etc/roles/literal/insertionRole.js b/src/etc/roles/literal/insertionRole.js index eb31e32e..3129120c 100644 --- a/src/etc/roles/literal/insertionRole.js +++ b/src/etc/roles/literal/insertionRole.js @@ -14,7 +14,14 @@ const insertionRole: ARIARoleDefinition = { 'aria-labelledby', ], props: {}, - relatedConcepts: [], + relatedConcepts: [ + { + concept: { + name: 'ins', + }, + module: 'HTML', + }, + ], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [], diff --git a/src/etc/roles/literal/linkRole.js b/src/etc/roles/literal/linkRole.js index 0a4eb7a5..eed3d575 100644 --- a/src/etc/roles/literal/linkRole.js +++ b/src/etc/roles/literal/linkRole.js @@ -39,17 +39,6 @@ const linkRole: ARIARoleDefinition = { }, module: 'HTML', }, - { - concept: { - attributes: [ - { - name: 'href', - }, - ], - name: 'link', - }, - module: 'HTML', - }, ], requireContextRole: [], requiredContextRole: [], diff --git a/src/etc/roles/literal/listboxRole.js b/src/etc/roles/literal/listboxRole.js index bb041081..cdc1d1bc 100644 --- a/src/etc/roles/literal/listboxRole.js +++ b/src/etc/roles/literal/listboxRole.js @@ -24,15 +24,15 @@ const listboxRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - '>1', - ], name: 'size', }, { name: 'multiple', }, ], + constraints: [ + 'the size attribute value is greater than 1', + ], name: 'select', }, module: 'HTML', @@ -41,12 +41,12 @@ const listboxRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - '>1', - ], name: 'size', }, ], + constraints: [ + 'the size attribute value is greater than 1', + ], name: 'select', }, module: 'HTML', @@ -58,13 +58,37 @@ const listboxRole: ARIARoleDefinition = { name: 'multiple', }, ], + constraints: [ + 'the multiple attribute value is greater than 1', + ], name: 'select', }, module: 'HTML', }, + { + concept: { + attributes: [ + { + name: 'aria-multiselectable', + value: 'true', + }, + ], + constraints: [ + 'the datalist selection model allows multiple option elements to be selected at a time', + ], + name: 'datalist', + }, + module: 'HTML', + }, { concept: { name: 'datalist', + attributes: [ + { + name: 'aria-multiselectable', + value: 'false', + }, + ], }, module: 'HTML', }, diff --git a/src/etc/roles/literal/listitemRole.js b/src/etc/roles/literal/listitemRole.js index 469a6dd0..145f3ca6 100644 --- a/src/etc/roles/literal/listitemRole.js +++ b/src/etc/roles/literal/listitemRole.js @@ -19,7 +19,9 @@ const listitemRole: ARIARoleDefinition = { { concept: { constraints: [ - 'direct descendant of ol, ul or menu', + 'direct descendant of ol', + 'direct descendant of ul', + 'direct descendant of menu', ], name: 'li', }, diff --git a/src/etc/roles/literal/markRole.js b/src/etc/roles/literal/markRole.js new file mode 100644 index 00000000..cf59506a --- /dev/null +++ b/src/etc/roles/literal/markRole.js @@ -0,0 +1,39 @@ +/** + * @flow + */ +const markRole: ARIARoleDefinition = { + abstract: false, + accessibleNameRequired: false, + baseConcepts: [], + childrenPresentational: false, + nameFrom: [ + 'prohibited', + ], + prohibitedProps: [], + props: { + 'aria-braillelabel': null, + 'aria-brailleroledescription': null, + 'aria-description': null, + }, + relatedConcepts: [ + { + concept: { + name: 'mark', + }, + module: 'HTML', + }, + ], + requireContextRole: [], + requiredContextRole: [], + requiredOwnedElements: [], + requiredProps: {}, + superClass: [ + [ + 'roletype', + 'structure', + 'section', + ], + ], +}; + +export default markRole; \ No newline at end of file diff --git a/src/etc/roles/literal/menuitemRole.js b/src/etc/roles/literal/menuitemRole.js index 3984e0eb..f8c8c3f0 100644 --- a/src/etc/roles/literal/menuitemRole.js +++ b/src/etc/roles/literal/menuitemRole.js @@ -25,18 +25,6 @@ const menuitemRole: ARIARoleDefinition = { }, module: 'JAPI', }, - { - concept: { - name: 'listitem', - }, - module: 'ARIA', - }, - { - concept: { - name: 'menuitem', - }, - module: 'HTML', - }, { concept: { name: 'option', diff --git a/src/etc/roles/literal/meterRole.js b/src/etc/roles/literal/meterRole.js index 71c40664..c4201cac 100644 --- a/src/etc/roles/literal/meterRole.js +++ b/src/etc/roles/literal/meterRole.js @@ -15,7 +15,14 @@ const meterRole: ARIARoleDefinition = { 'aria-valuemax': '100', 'aria-valuemin': '0', }, - relatedConcepts: [], + relatedConcepts: [ + { + concept: { + name: 'meter', + }, + module: 'HTML', + }, + ], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [], diff --git a/src/etc/roles/literal/paragraphRole.js b/src/etc/roles/literal/paragraphRole.js index db4f406e..7060a552 100644 --- a/src/etc/roles/literal/paragraphRole.js +++ b/src/etc/roles/literal/paragraphRole.js @@ -14,7 +14,14 @@ const paragraphRole: ARIARoleDefinition = { 'aria-labelledby', ], props: {}, - relatedConcepts: [], + relatedConcepts: [ + { + concept: { + name: 'p', + }, + module: 'HTML', + }, + ], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [], diff --git a/src/etc/roles/literal/presentationRole.js b/src/etc/roles/literal/presentationRole.js index ddbd4667..c9a14b5c 100644 --- a/src/etc/roles/literal/presentationRole.js +++ b/src/etc/roles/literal/presentationRole.js @@ -14,7 +14,20 @@ const presentationRole: ARIARoleDefinition = { 'aria-labelledby', ], props: {}, - relatedConcepts: [], + relatedConcepts: [ + { + concept: { + attributes: [ + { + name: 'alt', + value: '', + }, + ], + name: 'img', + }, + module: 'HTML', + }, + ], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [], diff --git a/src/etc/roles/literal/progressbarRole.js b/src/etc/roles/literal/progressbarRole.js index 7a78ee2c..5b57a2c7 100644 --- a/src/etc/roles/literal/progressbarRole.js +++ b/src/etc/roles/literal/progressbarRole.js @@ -20,6 +20,27 @@ const progressbarRole: ARIARoleDefinition = { }, module: 'HTML', }, + { + concept: { + attributes: [ + { + name: 'aria-valuemax', + }, + { + name: 'aria-valuemin', + value: 0, + }, + { + name: 'aria-valuenow', + }, + ], + constraints: [ + 'the progress bar is determinate', + ], + name: 'progress', + }, + module: 'HTML', + }, { concept: { name: 'status', diff --git a/src/etc/roles/literal/regionRole.js b/src/etc/roles/literal/regionRole.js index b1f4cf35..d212e3a5 100644 --- a/src/etc/roles/literal/regionRole.js +++ b/src/etc/roles/literal/regionRole.js @@ -16,9 +16,6 @@ const regionRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'set', - ], name: 'aria-label', }, ], @@ -30,9 +27,6 @@ const regionRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'set', - ], name: 'aria-labelledby', }, ], @@ -45,12 +39,6 @@ const regionRole: ARIARoleDefinition = { name: 'Device Independence Glossart perceivable unit', }, }, - { - concept: { - name: 'frame', - }, - module: 'HTML', - }, ], requireContextRole: [], requiredContextRole: [], diff --git a/src/etc/roles/literal/searchboxRole.js b/src/etc/roles/literal/searchboxRole.js index 71279bbb..62e3f4e0 100644 --- a/src/etc/roles/literal/searchboxRole.js +++ b/src/etc/roles/literal/searchboxRole.js @@ -16,9 +16,6 @@ const searchboxRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'undefined', - ], name: 'list', }, { @@ -26,6 +23,9 @@ const searchboxRole: ARIARoleDefinition = { value: 'search', }, ], + constraints: [ + 'the list attribute is not set', + ], name: 'input', }, module: 'HTML', diff --git a/src/etc/roles/literal/strongRole.js b/src/etc/roles/literal/strongRole.js index f30c232a..86f864f5 100644 --- a/src/etc/roles/literal/strongRole.js +++ b/src/etc/roles/literal/strongRole.js @@ -14,7 +14,14 @@ const strongRole: ARIARoleDefinition = { 'aria-labelledby', ], props: {}, - relatedConcepts: [], + relatedConcepts: [ + { + concept: { + name: 'strong', + }, + module: 'HTML', + }, + ], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [], diff --git a/src/etc/roles/literal/subscriptRole.js b/src/etc/roles/literal/subscriptRole.js index cb855db7..0707000d 100644 --- a/src/etc/roles/literal/subscriptRole.js +++ b/src/etc/roles/literal/subscriptRole.js @@ -14,7 +14,14 @@ const subscriptRole: ARIARoleDefinition = { 'aria-labelledby', ], props: {}, - relatedConcepts: [], + relatedConcepts: [ + { + concept: { + name: 'sub', + }, + module: 'HTML', + }, + ], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [], diff --git a/src/etc/roles/literal/superscriptRole.js b/src/etc/roles/literal/superscriptRole.js index 75369d9a..9d1039ff 100644 --- a/src/etc/roles/literal/superscriptRole.js +++ b/src/etc/roles/literal/superscriptRole.js @@ -14,7 +14,14 @@ const superscriptRole: ARIARoleDefinition = { 'aria-labelledby', ], props: {}, - relatedConcepts: [], + relatedConcepts: [ + { + concept: { + name: 'sup', + }, + module: 'HTML', + }, + ], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [], diff --git a/src/etc/roles/literal/switchRole.js b/src/etc/roles/literal/switchRole.js index 755d56a1..04aca726 100644 --- a/src/etc/roles/literal/switchRole.js +++ b/src/etc/roles/literal/switchRole.js @@ -15,9 +15,14 @@ const switchRole: ARIARoleDefinition = { relatedConcepts: [ { concept: { + attributes: [ + { + name: 'aria-checked', + }, + ], name: 'button', }, - module: 'ARIA', + module: 'HTML', }, ], requireContextRole: [], diff --git a/src/etc/roles/literal/textboxRole.js b/src/etc/roles/literal/textboxRole.js index 88ec5e12..9d80260f 100644 --- a/src/etc/roles/literal/textboxRole.js +++ b/src/etc/roles/literal/textboxRole.js @@ -24,19 +24,8 @@ const textboxRole: ARIARoleDefinition = { relatedConcepts: [ { concept: { - attributes: [ - { - constraints: [ - 'undefined', - ], - name: 'type', - }, - { - constraints: [ - 'undefined', - ], - name: 'list', - }, + constraints: [ + 'the list attribute is not set', ], name: 'input', }, @@ -45,17 +34,14 @@ const textboxRole: ARIARoleDefinition = { { concept: { attributes: [ - { - constraints: [ - 'undefined', - ], - name: 'list', - }, { name: 'type', value: 'email', }, ], + constraints: [ + 'the list attribute is not set', + ], name: 'input', }, module: 'HTML', @@ -63,17 +49,14 @@ const textboxRole: ARIARoleDefinition = { { concept: { attributes: [ - { - constraints: [ - 'undefined', - ], - name: 'list', - }, { name: 'type', value: 'tel', }, ], + constraints: [ + 'the list attribute is not set', + ], name: 'input', }, module: 'HTML', @@ -81,17 +64,14 @@ const textboxRole: ARIARoleDefinition = { { concept: { attributes: [ - { - constraints: [ - 'undefined', - ], - name: 'list', - }, { name: 'type', value: 'text', }, ], + constraints: [ + 'the list attribute is not set', + ], name: 'input', }, module: 'HTML', @@ -99,17 +79,14 @@ const textboxRole: ARIARoleDefinition = { { concept: { attributes: [ - { - constraints: [ - 'undefined', - ], - name: 'list', - }, { name: 'type', value: 'url', }, ], + constraints: [ + 'the list attribute is not set', + ], name: 'input', }, module: 'HTML', diff --git a/src/etc/roles/literal/timeRole.js b/src/etc/roles/literal/timeRole.js index adee4dee..785e531b 100644 --- a/src/etc/roles/literal/timeRole.js +++ b/src/etc/roles/literal/timeRole.js @@ -11,7 +11,14 @@ const timeRole: ARIARoleDefinition = { ], prohibitedProps: [], props: {}, - relatedConcepts: [], + relatedConcepts: [ + { + concept: { + name: 'time', + }, + module: 'HTML', + }, + ], requireContextRole: [], requiredContextRole: [], requiredOwnedElements: [], diff --git a/src/roleElementMap.js b/src/roleElementMap.js index 01b37cb9..6b62b95c 100644 --- a/src/roleElementMap.js +++ b/src/roleElementMap.js @@ -16,25 +16,21 @@ const keys = rolesMap.keys(); for (let i = 0; i < keys.length; i++) { const key: ARIARoleDefinitionKey = keys[i]; const role = rolesMap.get(key); + const relationConcepts: ARIARoleRelationConcepts = []; if (role) { const concepts = [].concat(role.baseConcepts, role.relatedConcepts); for (let k = 0; k < concepts.length; k++) { const relation: ARIARoleRelation = concepts[k]; if (relation.module === 'HTML') { const concept = relation.concept; - if (concept) { - const roleElementRelation: ?RoleElementRelation = roleElement.find((item) => item[0] === key); - let relationConcepts: ARIARoleRelationConcepts; - if (roleElementRelation) { - relationConcepts = roleElementRelation[1]; - } else { - relationConcepts = []; - } + if (concept != null) { relationConcepts.push(concept); - roleElement.push([key, relationConcepts]); } } } + if (relationConcepts.length > 0) { + roleElement.push([key, relationConcepts]); + } } }