8000 test: add test case of getChartSpecWithContext when chartType is circlePacking by zjyhhhher · Pull Request #257 · VisActor/VMind · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

test: add test case of getChartSpecWithContext when chartType is circlePacking #257

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

zjyhhhher
Copy link
Contributor

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Refactoring
  • Update dependency
  • Code style optimization
  • Test Case
  • Branch merge
  • Release
  • Site / documentation update
  • Demo update
  • Workflow
  • Other (about what?)

🔗 Related issue link

#238

🔗 Related PR link

🐞 Bugserver case id

💡 Background and solution

Background

This PR addresses the need to validate the correctness of getChartSpecWithContext() for circle packing charts, ensuring the method produces valid specifications for this chart type.

Solution

  1. Added dedicated test suite for circlePacking chart type, including Basic CirclePacking Chart, Bubble CirclePacking Chart and Multi-root CirclePacking Chart.
  2. Verified core property of spec including:
    • type
    • data.values
    • (Additional validations can be added upon request)
  3. Dynamic Data Generation: In my test case, I use a random generator to generate diverse numerical values and prevents hard-coded value dependencies.

📝 Changelog

Language Changelog
🇺🇸 English Added comprehensive unit tests for circle packing chart specifications covering basic circlepacking chart/bubble circlepacking chart and multi-root circle packing chart
🇨🇳 Chinese 新增圈套圆图单元测试,覆盖三种图场景

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

@github-actions github-actions bot added the vmind label May 27, 2025

const generateRandomValue = (min = 100, max = 2000) => Math.floor(Math.random() * (max - min + 1)) + min;

function generateDataStructure() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

生成层次数据的方法,可以考虑提取成公共的测试方法,方便其他层次数据相关图表,用于生成数据

//console.log("multi-root spec", JSON.stringify(spec, null, 2));
expect(chartType).toBe(ChartType.BubbleCirclePacking);
expect(spec.type).toBe('circlePacking');
expect(spec.data.values).toEqual(multi_root_data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这三个测试case 是为了覆盖什么内容呢,有没有跑过case1, case 2, case 3 分别能增加多少测试覆盖率呢

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新修改了一版test case(getChartSpecWithContext_circlePacking.test.ts)
完成了一下几个方面的测试,基本所有覆盖函数代码

功能项 覆盖情况
vennData 生成:测试3种不同的dataTable
revisedVChartType:检测spec.type
theme 处理 string/object两种情况
colors 与 chartTheme.colorScheme 的互斥逻辑
formatSimpleSpec 分支(type, title, dataZoom, label, indicator, palette, background)
bubbleCirclePackingData
bubbleCirclePackingField
bubbleCirclePackingDisplayConf
边界处理(空dataTable、缺失colors、空cell)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

测试覆盖率之后可以直接在packages/vmind下跑命令获取哈: npm run test-cov

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

circlePacking.ts:

File % Stmts % Branch % Funcs % Lines Uncovered Line #s
circlePacking.ts 100 85.71 100 100 18

image

@zjyhhhher zjyhhhher force-pushed the test/add-test-getChartSpecWithContext-CirclePackingChart branch from cb1d3fd to afa41f0 Compare June 2, 2025 16:52
…lePacking (add specific test for functions in circlePacking.ts)
@zjyhhhher
Copy link
Contributor Author

更新了一版,额外添加了针对circlePacking.ts中bubbleCirclePackingData bubbleCirclePackingField的单测,覆盖率:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0