Skip to content

test: add basic tests #1

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 1 commit into
base: main
Choose a base branch
from
Open

test: add basic tests #1

wants to merge 1 commit into from

Conversation

sanand0
Copy link
Contributor

@sanand0 sanand0 commented May 30, 2025

I've added initial Vitest tests for network.js and kpartite.js.

I introduced vitest and happy-dom for JavaScript testing and configured package.json with a test script and necessary devDependencies.

I created tests/network.test.js to test network.js:

  • It uses happy-dom to simulate a browser environment for DOM testing.
  • It includes an HTML fixture (tests/network.test.html) with D3.js loaded from CDN.
  • It verifies basic SVG rendering and the creation of node and link elements.
  • It checks data binding by inspecting D3's __data__ property on elements.
  • It ensures the nodeTag parameter functions as expected.

I also created tests/kpartite.test.js to unit test kpartite.js:

  • It directly tests the data transformation logic.
  • It verifies the structure and content of the generated nodes and links arrays.
  • It checks aggregation of values as defined by the function's parameters.

The test setup, file structure, and testing style are modeled after the practices in the sanand0/bootstrap-dark-theme repository, utilizing Vitest for the test runner and assertions.

I introduced `vitest` and `happy-dom` for JavaScript testing and configured `package.json` with a test script and necessary devDependencies.

I created `tests/network.test.js` to test `network.js`:
- It uses `happy-dom` to simulate a browser environment for DOM testing.
- It includes an HTML fixture (`tests/network.test.html`) with D3.js loaded from CDN.
- It verifies basic SVG rendering and the creation of node and link elements.
- It checks data binding by inspecting D3's `__data__` property on elements.
- It ensures the `nodeTag` parameter functions as expected.

I also created `tests/kpartite.test.js` to unit test `kpartite.js`:
- It directly tests the data transformation logic.
- It verifies the structure and content of the generated `nodes` and `links` arrays.
- It checks aggregation of values as defined by the function's parameters.

The test setup, file structure, and testing style are modeled after the practices in the `sanand0/bootstrap-dark-theme` repository, utilizing Vitest for the test runner and assertions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant