Skip to content

🧪 [testing improvement] Add unit tests for updateOptions#13

Open
jsem-nerad wants to merge 1 commit into
mainfrom
jules-add-update-options-tests-16837735816644289367
Open

🧪 [testing improvement] Add unit tests for updateOptions#13
jsem-nerad wants to merge 1 commit into
mainfrom
jules-add-update-options-tests-16837735816644289367

Conversation

@jsem-nerad

Copy link
Copy Markdown
Owner

🎯 What: The testing gap addressed
The updateOptions method in src/dotwave.js was previously untested. This PR adds unit tests to verify its core logic, ensuring that basic object merging works as expected and that this._createDots() is conditionally invoked when specific configuration options change (numDots, dotStretch, rotSmoothing).

📊 Coverage: What scenarios are now tested

  • Validates basic merging behavior of options object passed to updateOptions.
  • Verifies that dots are recreated when numDots changes.
  • Verifies that dots are recreated when dotStretch changes.
  • Verifies that dots are recreated when rotSmoothing changes.
  • Ensures that dots are not unnecessarily recreated when other independent property changes (e.g., dotColor, friction).

Result: The improvement in test coverage
Introduced a mock browser setup (tests/mock-browser.js) and a vanilla Node.js test runner (tests/updateOptions.test.js) that safely isolates side-effects to execute standalone JS test files. Test coverage has increased, helping guarantee stability for DotWave's reactive runtime modifications.


PR created automatically by Jules for task 16837735816644289367 started by @jsem-nerad

Co-authored-by: jsem-nerad <88319121+jsem-nerad@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings May 23, 2026 16:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a lightweight Node-based test harness and a minimal browser mock to unit test DotWave.prototype.updateOptions without requiring a real browser environment, improving confidence in runtime option updates.

Changes:

  • Added tests/mock-browser.js to stub enough DOM/Canvas APIs for src/dotwave.js to load under Node.
  • Added tests/updateOptions.test.js with unit tests covering option merging and conditional dot recreation when numDots, dotStretch, or rotSmoothing change.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
tests/mock-browser.js Introduces a basic DOM/window/canvas mock so DotWave can be constructed in Node tests.
tests/updateOptions.test.js Adds a small test runner and unit tests validating updateOptions merge behavior and _createDots() invocation conditions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/mock-browser.js
Comment on lines +15 to +16
class MockElement {
constructor(tagName) {
Comment thread tests/mock-browser.js
Comment on lines +54 to +57
querySelector: (selector) => {
if (selector === 'body') return new MockElement('body');
return new MockElement('div');
},
Comment on lines +3 to +6
const assert = require('assert');
// In node environment, the IIFE attaches DotWave to 'global' if window is not defined.
// Wait, our mock defines global.window, so it attaches to window.
const DotWave = global.window.DotWave;
Comment on lines +28 to +34
test('updateOptions should merge simple options', () => {
dotwave.updateOptions({ dotColor: 'red', numDots: 100 });
assert.strictEqual(dotwave.options.dotColor, 'red');
assert.strictEqual(dotwave.options.numDots, 100);
// Original default shouldn't change if not specified
assert.strictEqual(dotwave.options.backgroundColor, 'black');
});
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.

2 participants