-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 修复紧凑模式下单元格宽度计算忽略了icon宽度的问题 (#2673)
* fix: 修复存在字段标记时, 紧凑模式宽度计算错误 * fix: 修复紧凑模式下单元格宽度计算忽略了icon宽度的问题 * fix: 修改类型引用路径 * test: 补充utils单测 --------- Co-authored-by: lijinke666 <[email protected]> Co-authored-by: 张斌 <[email protected]>
- Loading branch information
1 parent
52dcea4
commit dd053c3
Showing
10 changed files
with
352 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { getDataCellIconStyle, normalizeIconCfg } from '@/utils/layout/icon'; | ||
|
||
describe('normalizeIconCfg Test', () => { | ||
test('should return a complete IconCfg object', () => { | ||
expect(normalizeIconCfg()).toEqual({ | ||
size: 0, | ||
position: 'right', | ||
margin: { | ||
left: 0, | ||
right: 0, | ||
}, | ||
}); | ||
}); | ||
|
||
test('should return the input object', () => { | ||
const iconCfg = { | ||
size: 10, | ||
position: 'left', | ||
margin: { | ||
left: 8, | ||
right: 8, | ||
}, | ||
}; | ||
expect(normalizeIconCfg(iconCfg)).toEqual(iconCfg); | ||
}); | ||
}); | ||
|
||
describe('getDataCellIconStyle Test', () => { | ||
const conditions = [ | ||
{ | ||
field: 'value', | ||
mapping: () => ({ fill: 'red' }), | ||
}, | ||
{ field: 'price', mapping: () => ({ fill: 'blue' }) }, | ||
{ field: /price/, mapping: () => ({ fill: 'orange' }), position: 'left' }, | ||
{ field: 'p', mapping: () => ({ fill: 'pink' }) }, | ||
]; | ||
test('should return default iconCfg object', () => { | ||
expect( | ||
getDataCellIconStyle( | ||
{ icon: conditions }, | ||
{ size: 10, margin: { left: 4, right: 4 } }, | ||
'errorField', | ||
), | ||
).toEqual({ | ||
size: 0, | ||
position: 'right', | ||
margin: { | ||
left: 0, | ||
right: 0, | ||
}, | ||
}); | ||
expect( | ||
getDataCellIconStyle( | ||
{ icon: [] }, | ||
{ size: 10, margin: { left: 4, right: 4 } }, | ||
'price', | ||
), | ||
).toEqual({ | ||
size: 0, | ||
position: 'right', | ||
margin: { | ||
left: 0, | ||
right: 0, | ||
}, | ||
}); | ||
}); | ||
test('should return correct iconCfg object', () => { | ||
expect( | ||
getDataCellIconStyle( | ||
{ icon: conditions }, | ||
{ size: 10, margin: { left: 4, right: 4 } }, | ||
'price', | ||
), | ||
).toEqual({ | ||
size: 10, | ||
position: 'left', | ||
margin: { | ||
left: 4, | ||
right: 4, | ||
}, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.