This repository was archived by the owner on Sep 21, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed
packages/devtools-components/src Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -66,17 +66,19 @@ describe("Tree", () => {
6666 expect ( mountTree ( ) ) . toBeTruthy ( ) ;
6767 } ) ;
6868
69- it ( "is accessible" , ( ) => {
70- const wrapper = mountTree ( ) ;
69+ it . only ( "is accessible" , ( ) => {
70+ const wrapper = mountTree ( {
71+ expanded : new Set ( "ABCDEFGHIJKLMNO" . split ( "" ) ) ,
72+ } ) ;
7173 expect ( wrapper . getDOMNode ( ) . getAttribute ( "role" ) ) . toBe ( "tree" ) ;
7274 expect ( wrapper . getDOMNode ( ) . getAttribute ( "tabIndex" ) ) . toBe ( "0" ) ;
7375
7476 getTreeNodes ( wrapper )
75- . everyWhere ( node => {
76- return typeof node . prop ( "id" ) !== "undefined"
77- && node . prop ( "role" ) === "treeitem"
78- && typeof node . prop ( "aria-level" ) !== "undefined" ;
79- } ) ;
77+ . everyWhere ( node => expect (
78+ node . prop ( "id" ) . startsWith ( "key-" )
79+ && node . prop ( "role" ) === "treeitem"
80+ && typeof node . prop ( "aria-level" ) !== "undefined"
81+ ) . toBe ( true ) ) ;
8082 } ) ;
8183
8284 it ( "renders as expected" , ( ) => {
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ const TreeNode = createFactory(createClass({
4646 displayName : "TreeNode" ,
4747
4848 propTypes : {
49+ id : PropTypes . any . isRequired ,
4950 index : PropTypes . number . isRequired ,
5051 depth : PropTypes . number . isRequired ,
5152 focused : PropTypes . bool . isRequired ,
@@ -65,6 +66,7 @@ const TreeNode = createFactory(createClass({
6566 render ( ) {
6667 const {
6768 depth,
69+ id,
6870 item,
6971 focused,
7072 expanded,
@@ -121,6 +123,7 @@ const TreeNode = createFactory(createClass({
121123
122124 return dom . div (
123125 {
126+ id,
124127 className : "tree-node" + ( focused ? " focused" : "" ) ,
125128 style : {
126129 paddingInlineStart,
@@ -697,8 +700,10 @@ const Tree = createClass({
697700
698701 const nodes = traversal . map ( ( v , i ) => {
699702 const { item, depth } = traversal [ i ] ;
703+ const key = this . props . getKey ( item , i ) ;
700704 return TreeNode ( {
701- key : this . props . getKey ( item , i ) ,
705+ key,
706+ id : key ,
702707 index : i ,
703708 item,
704709 depth,
You can’t perform that action at this time.
0 commit comments