New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(#19132): fix component tree defaultExpandAll does not work when u… #19148
Changes from 8 commits
2d409d2
bcffcc3
a915207
3bd2c80
fb751a7
744a6d0
3397ee6
c04c9fb
959ffba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,7 +1,7 @@ | ||||
import React from 'react'; | ||||
import { mount } from 'enzyme'; | ||||
import Tree from '../index'; | ||||
import { calcRangeKeys } from '../util'; | ||||
import { calcRangeKeys, getFullKeyListByTreeData } from '../util'; | ||||
|
||||
const { TreeNode } = Tree; | ||||
|
||||
|
@@ -32,4 +32,51 @@ describe('Tree util', () => { | |||
const target = ['0-0-0', '0-0-1', '0-1', '0-2', '0-2-0', '0-2-0-0', '0-2-0-1']; | ||||
expect(keys.sort()).toEqual(target.sort()); | ||||
}); | ||||
|
||||
it('calc range keys by treeData', () => { | ||||
const treeData = [ | ||||
{ | ||||
key: '0-0-0', | ||||
title: 'Folder', | ||||
children: [ | ||||
{ | ||||
title: 'Folder2', | ||||
key: '0-0-1', | ||||
children: [ | ||||
{ | ||||
title: 'File', | ||||
key: '0-0-2', | ||||
isLeaf: true, | ||||
}, | ||||
], | ||||
}, | ||||
], | ||||
}, | ||||
{ | ||||
key: '0-0-3', | ||||
title: 'Folder', | ||||
children: [ | ||||
{ | ||||
title: 'File', | ||||
key: '0-0-4', | ||||
isLeaf: true, | ||||
}, | ||||
{ | ||||
title: 'File', | ||||
key: '0-0-5', | ||||
isLeaf: true, | ||||
}, | ||||
{ | ||||
title: 'File', | ||||
key: '0-0-6', | ||||
isLeaf: true, | ||||
}, | ||||
], | ||||
}, | ||||
]; | ||||
|
||||
const keys = getFullKeyListByTreeData(treeData); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should test Tree component behavior instead of testing inner function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am sorry, this is my first contribution for ant-design, I have see documents but I still don't understand how to write this test, can you help me ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should I white test case in directory.test.js ? like this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just simulate the exact problem in test case, like test case in https://github.com/ant-design/ant-design/blob/master/components/tree/__tests__/directory.test.js or
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so this is right ? I don't sure...
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this test case can reflect the problem you meet, then it is right. |
||||
const target = ['0-0-0', '0-0-1', '0-0-2', '0-0-3', '0-0-4', '0-0-5', '0-0-6']; | ||||
expect(keys.sort()).toEqual(target.sort()); | ||||
}); | ||||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to:
treeData
priority should be higher than children.