update at 2026-02-13 17:44:25
This commit is contained in:
@@ -44,4 +44,65 @@ describe('core parser & sankey', () => {
|
||||
expect(table.headers.length).toBeGreaterThan(1);
|
||||
expect(table.rows.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('源数据非法时,告警包含单元格内容和位置', () => {
|
||||
const table = {
|
||||
headers: ['source', 'value', 'target'],
|
||||
rows: [['A', 'abc', 'T1']]
|
||||
};
|
||||
|
||||
const result = buildSankeyData(table, {
|
||||
sourceDataColumn: 1,
|
||||
sourceDescriptionColumns: [0],
|
||||
targetDescriptionColumns: [2],
|
||||
delimiter: '-'
|
||||
});
|
||||
|
||||
expect(result.meta.droppedRows).toBe(1);
|
||||
expect(result.meta.warnings[0]).toContain('第 2 行');
|
||||
expect(result.meta.warnings[0]).toContain('第 2 列');
|
||||
expect(result.meta.warnings[0]).toContain('value');
|
||||
expect(result.meta.warnings[0]).toContain('abc');
|
||||
});
|
||||
|
||||
it('源描述为空时,告警包含描述字段内容和位置', () => {
|
||||
const table = {
|
||||
headers: ['source', 'value', 'target'],
|
||||
rows: [['', '12', 'T1']]
|
||||
};
|
||||
|
||||
const result = buildSankeyData(table, {
|
||||
sourceDataColumn: 1,
|
||||
sourceDescriptionColumns: [0],
|
||||
targetDescriptionColumns: [2],
|
||||
delimiter: '-'
|
||||
});
|
||||
|
||||
expect(result.meta.droppedRows).toBe(1);
|
||||
expect(result.meta.warnings[0]).toContain('源描述为空');
|
||||
expect(result.meta.warnings[0]).toContain('第 1 列');
|
||||
expect(result.meta.warnings[0]).toContain('source');
|
||||
expect(result.meta.warnings[0]).toContain('(空)');
|
||||
});
|
||||
|
||||
it('目标描述为空时,告警包含描述字段内容和位置', () => {
|
||||
const table = {
|
||||
headers: ['source', 'value', 'target'],
|
||||
rows: [['S1', '12', '']]
|
||||
};
|
||||
|
||||
const result = buildSankeyData(table, {
|
||||
sourceDataColumn: 1,
|
||||
sourceDescriptionColumns: [0],
|
||||
targetDescriptionColumns: [2],
|
||||
delimiter: '-'
|
||||
});
|
||||
|
||||
expect(result.meta.droppedRows).toBe(1);
|
||||
expect(result.meta.warnings[0]).toContain('目标描述为空');
|
||||
expect(result.meta.warnings[0]).toContain('第 3 列');
|
||||
expect(result.meta.warnings[0]).toContain('target');
|
||||
expect(result.meta.warnings[0]).toContain('(空)');
|
||||
expect(result.meta.warnings[0]).toContain('无可继承的上方值');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user