Skip to content

Commit

Permalink
test(sankey): add test for data process
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc committed Dec 2, 2020
1 parent 68fc461 commit 9324328
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion __tests__/unit/plots/sankey/index-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ describe('sankey', () => {
y: [0.8358823529411765, 0.8358823529411765, 1, 1],
});

// sankey.destroy();
sankey.destroy();
});
});
30 changes: 30 additions & 0 deletions __tests__/unit/plots/sankey/util/data-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { transformDataToSankey } from '../../../../../src/plots/sankey/util/data';

describe('sankey util', () => {
it('transformDataToSankey', () => {
// @ts-ignore
expect(transformDataToSankey({})).toEqual({ nodes: [], links: [] });
// @ts-ignore
expect(transformDataToSankey(1)).toEqual({ nodes: [], links: [] });

expect(
transformDataToSankey(
[
{ source: '杭州', target: '上海', value: 1 },
{ source: '上海', target: '北京', value: 2 },
{ source: '杭州', target: '北京', value: 3 },
],
'source',
'target',
'value'
)
).toEqual({
nodes: [{ name: '杭州' }, { name: '上海' }, { name: '北京' }],
links: [
{ source: 0, target: 1, value: 1 },
{ source: 1, target: 2, value: 2 },
{ source: 0, target: 2, value: 3 },
],
});
});
});

0 comments on commit 9324328

Please sign in to comment.