Skip to content

test: add basic tests - #1

Open
sanand0 wants to merge 1 commit into
mainfrom
add-vitest-tests
Open

test: add basic tests#1
sanand0 wants to merge 1 commit into
mainfrom
add-vitest-tests

Conversation

@sanand0

@sanand0 sanand0 commented May 30, 2025

Copy link
Copy Markdown
Contributor

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