From 8cd4f2339518e27b3f2266d312bde0a4e62364c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Ren=C3=A9e=20Beach?= Date: Sat, 29 Oct 2022 17:07:45 -0700 Subject: [PATCH] Audited and updated roles source of truth to HTML Accessibility API Mapping 1.0 --- __tests__/src/ariaPropsMaps-test.js | 666 ++------- __tests__/src/domMap-test.js | 1554 +++----------------- __tests__/src/elementRoleMap-test.js | 1217 +++------------ __tests__/src/roleElementMap-test.js | 706 ++------- __tests__/src/rolesMap-test.js | 1332 +++-------------- flow/aria.js | 92 +- scripts/roles.json | 670 ++++++--- src/ariaPropsMap.js | 9 + src/elementRoleMap.js | 3 +- src/etc/roles/abstract/commandRole.js | 9 +- src/etc/roles/abstract/roletypeRole.js | 6 - src/etc/roles/ariaLiteralRoles.js | 2 + src/etc/roles/dpub/docBacklinkRole.js | 2 +- src/etc/roles/literal/bannerRole.js | 2 +- src/etc/roles/literal/blockquoteRole.js | 9 +- src/etc/roles/literal/buttonRole.js | 3 - src/etc/roles/literal/captionRole.js | 9 +- src/etc/roles/literal/cellRole.js | 15 +- src/etc/roles/literal/codeRole.js | 9 +- src/etc/roles/literal/columnheaderRole.js | 24 +- src/etc/roles/literal/comboboxRole.js | 79 +- src/etc/roles/literal/complementaryRole.js | 15 + src/etc/roles/literal/contentinfoRole.js | 2 +- src/etc/roles/literal/deletionRole.js | 9 +- src/etc/roles/literal/documentRole.js | 2 +- src/etc/roles/literal/emphasisRole.js | 9 +- src/etc/roles/literal/formRole.js | 9 - src/etc/roles/literal/genericRole.js | 120 +- src/etc/roles/literal/gridRole.js | 15 +- src/etc/roles/literal/gridcellRole.js | 6 - src/etc/roles/literal/groupRole.js | 6 + src/etc/roles/literal/headingRole.js | 42 + src/etc/roles/literal/imgRole.js | 22 - src/etc/roles/literal/insertionRole.js | 9 +- src/etc/roles/literal/linkRole.js | 11 - src/etc/roles/literal/listboxRole.js | 36 +- src/etc/roles/literal/listitemRole.js | 4 +- src/etc/roles/literal/markRole.js | 39 + src/etc/roles/literal/menuitemRole.js | 12 - src/etc/roles/literal/meterRole.js | 9 +- src/etc/roles/literal/paragraphRole.js | 9 +- src/etc/roles/literal/presentationRole.js | 15 +- src/etc/roles/literal/progressbarRole.js | 21 + src/etc/roles/literal/regionRole.js | 23 +- src/etc/roles/literal/searchboxRole.js | 6 +- src/etc/roles/literal/strongRole.js | 9 +- src/etc/roles/literal/subscriptRole.js | 9 +- src/etc/roles/literal/superscriptRole.js | 9 +- src/etc/roles/literal/switchRole.js | 7 +- src/etc/roles/literal/textboxRole.js | 57 +- src/etc/roles/literal/timeRole.js | 9 +- src/roleElementMap.js | 14 +- 52 files changed, 1905 insertions(+), 5078 deletions(-) create mode 100644 src/etc/roles/literal/markRole.js 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..43d4fd31 100644 --- a/__tests__/src/elementRoleMap-test.js +++ b/__tests__/src/elementRoleMap-test.js @@ -1,196 +1,142 @@ 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": "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"]], + [{"name": "caption"}, ["caption"]], + [{"constraints": ["ancestor table element has table role"], "name": "td"}, ["cell"]], + [{"constraints": ["is not a column header", "is not a row header", "is not a column group header", "is not a row group header", "ancestor table element has table role"], "name": "th"}, ["cell"]], + [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}, ["checkbox"]], + [{"name": "code"}, ["code"]], + [{"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": "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"]], + [{"constraints": ["scoped to the body element", "scoped to the main element"], "name": "aside"}, ["complementary"]], + [{"constraints": ["scoped to a sectioning content element", "scoped to a sectioning root element other than body", "has an accessible name"], "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"]], + [{"constraints": ["does not have an accessible name"],"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"]], + [{"constraints": ["does not have an accessible name"], "name": "section"}, ["generic"]], + [{"name": "small"}, ["generic"]], + [{"name": "span"}, ["generic"]], + [{"name": "u"}, ["generic"]], + [{"name": "td"}, ["gridcell"]], + [{"name": "details"}, ["group"]], + [{"name": "fieldset"}, ["group"]], + [{"name": "optgroup"}, ["group"]], + [{"name": "address"}, ["group"]], + [{"attributes": [{"name": "aria-level", "value": "1"}], "name": "h1"}, ["heading"]], + [{"attributes": [{"name": "aria-level", "value": "2"}], "name": "h2"}, ["heading"]], + [{"name": "h2"}, ["heading"]], + [{"attributes": [{"name": "aria-level", "value": "3"}], "name": "h3"}, ["heading"]], + [{"attributes": [{"name": "aria-level", "value": "4"}], "name": "h4"}, ["heading"]], + [{"attributes": [{"name": "aria-level", "value": "5"}], "name": "h5"}, ["heading"]], + [{"attributes": [{"name": "aria-level", "value": "6"}], "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"]], + [{"constraints": ["has an accessible name"], "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": [{"name": "scope", "value": "rowgroup"}], "name": "th"}, ["rowheader"]], + [{"attributes": [{"name": "list"}, {"name": "type", "value": "search"}], "constraints": ["the list attribute is not set"], "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": "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"]], + [{"attributes": [{"name": "aria-multiline", "value": "true"}], "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 +145,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 +182,7 @@ describe('elementRoleMap API', function () { name: 'fake element', })).toBeUndefined(); }); - it('has', function () { + it('has()', function () { expect(elementRoleMap.has({ attributes: [ { name: 'href' } @@ -426,381 +196,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 +229,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(119); + }); + 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..abc3b4f2 100644 --- a/__tests__/src/roleElementMap-test.js +++ b/__tests__/src/roleElementMap-test.js @@ -1,112 +1,82 @@ 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": "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"}]], + ["caption", [{"name": "caption"}]], + ["cell", [{"constraints": ["ancestor table element has table role"], "name": "td"}, {"constraints": ["is not a column header", "is not a row header", "is not a column group header", "is not a row group header", "ancestor table element has table role"], "name": "th"}]], + ["checkbox", [{"attributes": [{"name": "type", "value": "checkbox"}], "name": "input"}]], + ["code", [{"name": "code"}]], + ["columnheader", [{"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", [{"constraints": ["scoped to the body element", "scoped to the main element"], "name": "aside"}, {"constraints": ["scoped to a sectioning content element", "scoped to a sectioning root element other than body", "has an accessible name"], "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"}, {"constraints": ["does not have an accessible name"], "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"}, {"constraints": ["does not have an accessible name"], "name": "section"}, {"name": "small"}, {"name": "span"}, {"name": "u"}]], + ["grid", [{"attributes": [{"name": "role", "value": "grid"}], "name": "table"}]], + ["gridcell", [{"name": "td"}]], + ["group", [{"name": "details"}, {"name": "fieldset"}, {"name": "optgroup"}, {"name": "address"}]], + ["heading", [{"attributes": [{"name": "aria-level", "value": "1"}], "name": "h1"}, {"attributes": [{"name": "aria-level", "value": "2"}], "name": "h2"}, {"name": "h2"}, {"attributes": [{"name": "aria-level", "value": "3"}], "name": "h3"}, {"attributes": [{"name": "aria-level", "value": "4"}], "name": "h4"}, {"attributes": [{"name": "aria-level", "value": "5"}], "name": "h5"}, {"attributes": [{"name": "aria-level", "value": "6"}], "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"}]], + ["listitem", [{"constraints": ["direct descendant of ol", "direct descendant of ul", "direct descendant of menu"], "name": "li"}]], + ["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, ul or menu"], "name": "li"}]], + ["main", [{"name": "main"}]], + ["mark", [{"name": "mark"}]], + ["math", [{"name": "math"}]], + ["menuitem", [{"name": "menuitem"}]], + ["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", [{"constraints": ["has an accessible name"], "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": [{"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"}, {"attributes": [{"name": "aria-multiline", "value": "true"}], "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 +85,61 @@ 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": "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(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 +148,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(56); + }); + 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..7f4c1daf 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,28 +177,38 @@ 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 * strings correspond to a super class in the inheritance chain of this * role. Roles may have more than one inheritance chain, which is why - * this property is an array of arrays and not a single array. */ + * this attribute 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,50 @@ 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< + | 'has an accessible name' + | 'does not have an accessible name' + | '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' + | 'is not a column header' + | 'is not a row header' + | 'is not a column group header' + | 'is not a row group header' + | '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..aeac103c 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": [], @@ -263,7 +270,6 @@ "concept": { "attributes": [ { - "constraints": ["set"], "name": "aria-pressed" }, { @@ -391,7 +397,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "caption" + }, + "module": "HTML" + } + ], "requiredContextRole": ["figure", "grid", "table"], "requiredOwnedElements": [], "requiredProps": [], @@ -429,10 +442,23 @@ "relatedConcepts": [ { "concept": { - "constraints": ["descendant of table"], + "constraints": ["ancestor table element has table role"], "name": "td" }, "module": "HTML" + }, + { + "concept": { + "constraints": [ + "is not a column header", + "is not a row header", + "is not a column group header", + "is not a row group header", + "ancestor table element has table role" + ], + "name": "th" + }, + "module": "HTML" } ], "requiredContextRole": ["row"], @@ -520,7 +546,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "code" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -566,13 +599,26 @@ ], "relatedConcepts": [ { - "attributes": [ - { - "name": "scope", - "value": "col" - } - ], "concept": { + "attributes": [ + { + "name": "scope", + "value": "col" + } + ], + "name": "th" + }, + "module": "HTML" + }, + { + + "concept": { + "attributes": [ + { + "name": "scope", + "value": "colgroup" + } + ], "name": "th" }, "module": "HTML" @@ -622,7 +668,9 @@ "concept": { "attributes": [ { - "constraints": ["set"], + "name": "aria-controls" + }, + { "name": "list" }, { @@ -630,6 +678,9 @@ "value": "email" } ], + "constraints": [ + "the aria-controls attribute is set to the same value as the list attribute" + ], "name": "input" }, "module": "HTML" @@ -638,7 +689,9 @@ "concept": { "attributes": [ { - "constraints": ["set"], + "name": "aria-controls" + }, + { "name": "list" }, { @@ -646,6 +699,9 @@ "value": "search" } ], + "constraints": [ + "the aria-controls attribute is set to the same value as the list attribute" + ], "name": "input" }, "module": "HTML" @@ -654,7 +710,9 @@ "concept": { "attributes": [ { - "constraints": ["set"], + "name": "aria-controls" + }, + { "name": "list" }, { @@ -662,6 +720,9 @@ "value": "tel" } ], + "constraints": [ + "the aria-controls attribute is set to the same value as the list attribute" + ], "name": "input" }, "module": "HTML" @@ -670,7 +731,9 @@ "concept": { "attributes": [ { - "constraints": ["set"], + "name": "aria-controls" + }, + { "name": "list" }, { @@ -678,6 +741,9 @@ "value": "text" } ], + "constraints": [ + "the aria-controls attribute is set to the same value as the list attribute" + ], "name": "input" }, "module": "HTML" @@ -686,7 +752,9 @@ "concept": { "attributes": [ { - "constraints": ["set"], + "name": "aria-controls" + }, + { "name": "list" }, { @@ -694,6 +762,9 @@ "value": "url" } ], + "constraints": [ + "the aria-controls attribute is set to the same value as the list attribute" + ], "name": "input" }, "module": "HTML" @@ -702,7 +773,9 @@ "concept": { "attributes": [ { - "constraints": ["set"], + "name": "aria-controls" + }, + { "name": "list" }, { @@ -710,6 +783,9 @@ "value": "url" } ], + "constraints": [ + "the aria-controls attribute is set to the same value as the list attribute" + ], "name": "input" }, "module": "HTML" @@ -718,29 +794,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 +844,7 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [ - { - "concept": { - "name": "menuitem" - }, - "module": "HTML" - } - ], + "relatedConcepts": [], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -824,6 +878,21 @@ "relatedConcepts": [ { "concept": { + "constraints": [ + "scoped to the body element", + "scoped to the main element" + ], + "name": "aside" + }, + "module": "HTML" + }, + { + "concept": { + "constraints": [ + "scoped to a sectioning content element", + "scoped to a sectioning root element other than body", + "has an accessible name" + ], "name": "aside" }, "module": "HTML" @@ -895,7 +964,7 @@ "relatedConcepts": [ { "concept": { - "constraints": ["direct descendant of document"], + "constraints": ["scoped to the body element"], "name": "footer" }, "module": "HTML" @@ -967,7 +1036,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "del" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -1223,7 +1299,7 @@ "abstract": false, "accessibleNameRequired": true, "childrenPresentational": false, - "nameFrom": ["author", "content"], + "nameFrom": ["author", "contents"], "prohibitedProps": [], "props": [ "aria-atomic", @@ -2734,7 +2810,7 @@ }, { "concept": { - "name": "body" + "name": "html" }, "module": "HTML" } @@ -2767,7 +2843,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "em" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -2872,7 +2955,6 @@ "concept": { "attributes": [ { - "constraints": ["set"], "name": "aria-label" } ], @@ -2884,7 +2966,6 @@ "concept": { "attributes": [ { - "constraints": ["set"], "name": "aria-labelledby" } ], @@ -2896,7 +2977,6 @@ "concept": { "attributes": [ { - "constraints": ["set"], "name": "name" } ], @@ -2934,9 +3014,49 @@ "aria-roledescription" ], "relatedConcepts": [ + { "concept": { - "name": "span" + "name": "a" + }, + "module": "HTML" + }, + { + "concept": { + "name": "area" + }, + "module": "HTML" + }, + { + "concept": { + "constraints": [ + "does not have an accessible name" + ], + "name": "aside" + }, + "module": "HTML" + }, + { + "concept": { + "name": "b" + }, + "module": "HTML" + }, + { + "concept": { + "name": "bdo" + }, + "module": "HTML" + }, + { + "concept": { + "name": "body" + }, + "module": "HTML" + }, + { + "concept": { + "name": "data" }, "module": "HTML" }, @@ -2945,6 +3065,85 @@ "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": { + "constraints": [ + "does not have an accessible name" + ], + "name": "section" + }, + "module": "HTML" + }, + { + "concept": { + "name": "small" + }, + "module": "HTML" + }, + { + "concept": { + "name": "span" + }, + "module": "HTML" + }, + { + "concept": { + "name": "u" + }, + "module": "HTML" } ], "requiredContextRole": [], @@ -3136,20 +3335,7 @@ "aria-roledescription", "aria-rowcount" ], - "relatedConcepts": [ - { - "concept": { - "attributes": [ - { - "name": "role", - "value": "grid" - } - ], - "name": "table" - }, - "module": "HTML" - } - ], + "relatedConcepts": [], "requiredContextRole": [], "requiredOwnedElements": [["row"], ["row", "rowgroup"]], "requiredProps": [], @@ -3195,12 +3381,6 @@ "relatedConcepts": [ { "concept": { - "attributes": [ - { - "name": "role", - "value": "gridcell" - } - ], "name": "td" }, "module": "HTML" @@ -3256,6 +3436,12 @@ "name": "optgroup" }, "module": "HTML" + }, + { + "concept": { + "name": "address" + }, + "module": "HTML" } ], "requiredContextRole": [], @@ -3292,10 +3478,28 @@ "relatedConcepts": [ { "concept": { + "attributes": [ + { + "name": "aria-level", + "value": "1" + } + ], "name": "h1" }, "module": "HTML" }, + { + "concept": { + "attributes": [ + { + "name": "aria-level", + "value": "2" + } + ], + "name": "h2" + }, + "module": "HTML" + }, { "concept": { "name": "h2" @@ -3304,24 +3508,48 @@ }, { "concept": { + "attributes": [ + { + "name": "aria-level", + "value": "3" + } + ], "name": "h3" }, "module": "HTML" }, { "concept": { + "attributes": [ + { + "name": "aria-level", + "value": "4" + } + ], "name": "h4" }, "module": "HTML" }, { "concept": { + "attributes": [ + { + "name": "aria-level", + "value": "5" + } + ], "name": "h5" }, "module": "HTML" }, { "concept": { + "attributes": [ + { + "name": "aria-level", + "value": "6" + } + ], "name": "h6" }, "module": "HTML" @@ -3360,24 +3588,6 @@ "relatedConcepts": [ { "concept": { - "attributes": [ - { - "constraints": ["set"], - "name": "alt" - } - ], - "name": "img" - }, - "module": "HTML" - }, - { - "concept": { - "attributes": [ - { - "constraints": ["undefined"], - "name": "alt" - } - ], "name": "img" }, "module": "HTML" @@ -3456,7 +3666,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "ins" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -3543,17 +3760,6 @@ "name": "area" }, "module": "HTML" - }, - { - "concept": { - "attributes": [ - { - "name": "href" - } - ], - "name": "link" - }, - "module": "HTML" } ], "requiredContextRole": [], @@ -3650,13 +3856,15 @@ "concept": { "attributes": [ { - "constraints": [">1"], "name": "size" }, { "name": "multiple" } ], + "constraints":[ + "the size attribute value is greater than 1" + ], "name": "select" }, "module": "HTML" @@ -3665,10 +3873,12 @@ "concept": { "attributes": [ { - "constraints": [">1"], "name": "size" } ], + "constraints":[ + "the size attribute value is greater than 1" + ], "name": "select" }, "module": "HTML" @@ -3680,16 +3890,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 +3973,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 +4063,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 +4324,6 @@ }, "module": "JAPI" }, - { - "concept": { - "name": "listitem" - }, - "module": "ARIA" - }, - { - "concept": { - "name": "menuitem" - }, - "module": "HTML" - }, { "concept": { "name": "option" @@ -4194,7 +4461,14 @@ ["aria-valuemax", "100"], ["aria-valuemin", "0"] ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "meter" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": ["aria-valuenow"], @@ -4360,7 +4634,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "p" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -4389,7 +4670,20 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "attributes": [ + { + "name": "alt", + "value": "" + } + ], + "name": "img" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -4431,6 +4725,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" @@ -4598,23 +4913,8 @@ "relatedConcepts": [ { "concept": { - "attributes": [ - { - "constraints": ["set"], - "name": "aria-label" - } - ], - "name": "section" - }, - "module": "HTML" - }, - { - "concept": { - "attributes": [ - { - "constraints": ["set"], - "name": "aria-labelledby" - } + "constraints":[ + "has an accessible name" ], "name": "section" }, @@ -4663,12 +4963,6 @@ "aria-roledescription" ], "relatedConcepts": [ - { - "concept": { - "name": "rel" - }, - "module": "HTML" - }, { "concept": { "name": "role" @@ -4966,7 +5260,6 @@ "concept": { "attributes": [ { - "constraints": ["undefined"], "name": "list" }, { @@ -4974,6 +5267,9 @@ "value": "search" } ], + "constraints":[ + "the list attribute is not set" + ], "name": "input" }, "module": "HTML" @@ -5312,7 +5608,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "strong" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -5372,7 +5675,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "sub" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -5401,7 +5711,14 @@ "aria-relevant", "aria-roledescription" ], - "relatedConcepts": [], + "relatedConcepts": [ + { + "concept": { + "name": "sup" + }, + "module": "HTML" + } + ], "requiredContextRole": [], "requiredOwnedElements": [], "requiredProps": [], @@ -5442,9 +5759,12 @@ "relatedConcepts": [ { "concept": { + "attributes":[{ + "name": "aria-checked" + }], "name": "button" }, - "module": "ARIA" + "module": "HTML" } ], "requiredContextRole": [], @@ -5685,15 +6005,8 @@ "relatedConcepts": [ { "concept": { - "attributes": [ - { - "constraints": ["undefined"], - "name": "type" - }, - { - "constraints": ["undefined"], - "name": "list" - } + "constraints":[ + "the list attribute is not set" ], "name": "input" }, @@ -5702,15 +6015,14 @@ { "concept": { "attributes": [ - { - "constraints": ["undefined"], - "name": "list" - }, { "name": "type", "value": "email" } ], + "constraints":[ + "the list attribute is not set" + ], "name": "input" }, "module": "HTML" @@ -5718,15 +6030,14 @@ { "concept": { "attributes": [ - { - "constraints": ["undefined"], - "name": "list" - }, { "name": "type", "value": "tel" } ], + "constraints":[ + "the list attribute is not set" + ], "name": "input" }, "module": "HTML" @@ -5734,15 +6045,14 @@ { "concept": { "attributes": [ - { - "constraints": ["undefined"], - "name": "list" - }, { "name": "type", "value": "text" } ], + "constraints":[ + "the list attribute is not set" + ], "name": "input" }, "module": "HTML" @@ -5750,15 +6060,14 @@ { "concept": { "attributes": [ - { - "constraints": ["undefined"], - "name": "list" - }, { "name": "type", "value": "url" } ], + "constraints":[ + "the list attribute is not set" + ], "name": "input" }, "module": "HTML" @@ -5771,6 +6080,12 @@ }, { "concept": { + "attributes":[ + { + "name": "aria-multiline", + "value": "true" + } + ], "name": "textarea" }, "module": "HTML" @@ -5806,7 +6121,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..7e76c5e9 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) { 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/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..f5bb7e0e 100644 --- a/src/etc/roles/literal/buttonRole.js +++ b/src/etc/roles/literal/buttonRole.js @@ -22,9 +22,6 @@ const buttonRole: ARIARoleDefinition = { concept: { attributes: [ { - constraints: [ - 'set', - ], name: 'aria-pressed', }, { 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..01b915d9 100644 --- a/src/etc/roles/literal/cellRole.js +++ b/src/etc/roles/literal/cellRole.js @@ -21,12 +21,25 @@ const cellRole: ARIARoleDefinition = { { concept: { constraints: [ - 'descendant of table', + 'ancestor table element has table role', ], name: 'td', }, module: 'HTML', }, + { + concept: { + constraints: [ + 'is not a column header', + 'is not a row header', + 'is not a column group header', + 'is not a row group header', + 'ancestor table element has table role', + ], + name: 'th', + }, + module: 'HTML', + }, ], requireContextRole: [ 'row', 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..b1eadfb4 100644 --- a/src/etc/roles/literal/columnheaderRole.js +++ b/src/etc/roles/literal/columnheaderRole.js @@ -16,13 +16,25 @@ const columnheaderRole: ARIARoleDefinition = { }, relatedConcepts: [ { - attributes: [ - { - name: 'scope', - value: 'col', - }, - ], concept: { + attributes: [ + { + name: 'scope', + value: 'col', + }, + ], + name: 'th', + }, + module: 'HTML', + }, + { + concept: { + attributes: [ + { + name: 'scope', + value: 'colgroup', + }, + ], name: 'th', }, module: 'HTML', 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..e90b9493 100644 --- a/src/etc/roles/literal/complementaryRole.js +++ b/src/etc/roles/literal/complementaryRole.js @@ -14,6 +14,21 @@ const complementaryRole: ARIARoleDefinition = { relatedConcepts: [ { concept: { + constraints: [ + 'scoped to the body element', + 'scoped to the main element', + ], + name: 'aside', + }, + module: 'HTML', + }, + { + concept: { + constraints: [ + 'scoped to a sectioning content element', + 'scoped to a sectioning root element other than body', + 'has an accessible name', + ], name: 'aside', }, module: 'HTML', 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..fc6f323d 100644 --- a/src/etc/roles/literal/genericRole.js +++ b/src/etc/roles/literal/genericRole.js @@ -17,7 +17,46 @@ const genericRole: ARIARoleDefinition = { relatedConcepts: [ { concept: { - name: 'span', + name: 'a', + }, + module: 'HTML', + }, + { + concept: { + name: 'area', + }, + module: 'HTML', + }, + { + concept: { + constraints: [ + 'does not have an accessible name', + ], + 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 +66,85 @@ 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: { + constraints: [ + 'does not have an accessible name', + ], + 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..fad39c11 100644 --- a/src/etc/roles/literal/gridcellRole.js +++ b/src/etc/roles/literal/gridcellRole.js @@ -24,12 +24,6 @@ const gridcellRole: ARIARoleDefinition = { relatedConcepts: [ { concept: { - attributes: [ - { - name: 'role', - value: 'gridcell', - }, - ], name: 'td', }, module: 'HTML', 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/headingRole.js b/src/etc/roles/literal/headingRole.js index 7a3537b2..0e24214d 100644 --- a/src/etc/roles/literal/headingRole.js +++ b/src/etc/roles/literal/headingRole.js @@ -17,36 +17,78 @@ const headingRole: ARIARoleDefinition = { relatedConcepts: [ { concept: { + attributes: [ + { + name: 'aria-level', + value: '1', + }, + ], name: 'h1', }, module: 'HTML', }, { concept: { + attributes: [ + { + name: 'aria-level', + value: '2', + }, + ], name: 'h2', }, module: 'HTML', }, { concept: { + name: 'h2', + }, + module: 'HTML', + }, + { + concept: { + attributes: [ + { + name: 'aria-level', + value: '3', + }, + ], name: 'h3', }, module: 'HTML', }, { concept: { + attributes: [ + { + name: 'aria-level', + value: '4', + }, + ], name: 'h4', }, module: 'HTML', }, { concept: { + attributes: [ + { + name: 'aria-level', + value: '5', + }, + ], name: 'h5', }, module: 'HTML', }, { concept: { + attributes: [ + { + name: 'aria-level', + value: '6', + }, + ], name: 'h6', }, module: 'HTML', 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..f33ac1fe 100644 --- a/src/etc/roles/literal/regionRole.js +++ b/src/etc/roles/literal/regionRole.js @@ -14,27 +14,8 @@ const regionRole: ARIARoleDefinition = { relatedConcepts: [ { concept: { - attributes: [ - { - constraints: [ - 'set', - ], - name: 'aria-label', - }, - ], - name: 'section', - }, - module: 'HTML', - }, - { - concept: { - attributes: [ - { - constraints: [ - 'set', - ], - name: 'aria-labelledby', - }, + constraints: [ + 'has an accessible name', ], name: 'section', }, 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..82a446da 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', @@ -122,6 +99,12 @@ const textboxRole: ARIARoleDefinition = { }, { concept: { + attributes: [ + { + name: 'aria-multiline', + value: 'true', + }, + ], name: 'textarea', }, 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]); + } } }