-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix: 修复编辑表的输入框未回填格式化后的数据 close #2528 * fix: 修复循环引用 * fix: 编辑后不应该再次格式化 * fix: 移除定义 * test: 修复单测 * test: 增加单测
- Loading branch information
1 parent
31cc240
commit 8d9c5b2
Showing
19 changed files
with
168 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* @description spec for issue #2528 | ||
* https://github.com/antvis/S2/issues/2528 | ||
*/ | ||
|
||
import * as mockDataConfig from '../data/simple-table-data.json'; | ||
import { getContainer } from '../util/helpers'; | ||
import type { SpreadSheet, S2DataConfig, S2Options } from '@/index'; | ||
import { TableSheet } from '@/sheet-type'; | ||
|
||
const s2DataConfig: S2DataConfig = { | ||
...mockDataConfig, | ||
meta: [{ field: 'cost', formatter: (v) => `${v}-@` }], | ||
}; | ||
|
||
const s2Options: S2Options = { | ||
width: 800, | ||
height: 400, | ||
}; | ||
|
||
describe('Table Sheet Editable Formatter Tests', () => { | ||
let s2: SpreadSheet; | ||
|
||
beforeEach(() => { | ||
s2 = new TableSheet(getContainer(), s2DataConfig, s2Options); | ||
|
||
s2.render(); | ||
}); | ||
|
||
test('should get formatted data', () => { | ||
const costValues = s2.interaction | ||
.getPanelGroupAllDataCells() | ||
.filter((cell) => cell.getMeta().valueField === 'cost') | ||
.map((cell) => cell.getFieldValue()); | ||
|
||
expect(costValues).toEqual(['2-@', '2-@', '2-@']); | ||
}); | ||
|
||
test('should only format data once after data edited', () => { | ||
const id = '0-root[&]cost'; | ||
const inputValue = 'test'; | ||
|
||
// 模拟一次编辑 (更新第一行的 cost) | ||
const displayData = s2.dataSet.getDisplayDataSet(); | ||
displayData[0].cost = inputValue; | ||
s2.dataSet.displayFormattedValueMap?.set(id, inputValue); | ||
|
||
s2.render(); | ||
|
||
const costValues = s2.interaction | ||
.getPanelGroupAllDataCells() | ||
.filter((cell) => cell.getMeta().valueField === 'cost') | ||
.map((cell) => cell.getFieldValue()); | ||
|
||
expect(costValues).toEqual([inputValue, '2-@', '2-@']); | ||
}); | ||
}); |
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
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
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
Oops, something went wrong.