Skip to content

Commit 18b04b8

Browse files
committed
Cover the remaining scene-manager branches after the merge
Adds tests for rendering without a build volume, a rebuild request firing after clear, and construction without a build volume, keeping the scene-manager.ts coverage gate at 100%.
1 parent c364f6f commit 18b04b8

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

src/__tests__/scene-manager-properties.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,13 @@ describe('SceneManager properties', () => {
322322

323323
expect(sceneManager.buildVolume).toBeUndefined();
324324
});
325+
326+
test('render works without a build volume', () => {
327+
sceneManager.buildVolume = undefined;
328+
329+
expect(() => sceneManager.render()).not.toThrow();
330+
expect(extrusionGroup(sceneManager).children.length).toBeGreaterThan(0);
331+
});
325332
});
326333

327334
describe('clear', () => {
@@ -384,6 +391,17 @@ describe('SceneManager properties', () => {
384391

385392
expect(extrusionGroup(sceneManager).children.length).toBeGreaterThan(0);
386393
});
394+
395+
test('a rebuild request after clear does not redraw the dropped job', () => {
396+
vi.useFakeTimers();
397+
sceneManager.clear();
398+
const spy = vi.spyOn(sceneManager, 'render');
399+
400+
sceneManager.lineWidth = 5;
401+
vi.advanceTimersByTime(ObjectsManager.rebuildDebounce);
402+
403+
expect(spy).not.toHaveBeenCalled();
404+
});
387405
});
388406

389407
describe('disableGradient', () => {
@@ -507,6 +525,15 @@ describe('SceneManager properties', () => {
507525
);
508526
});
509527

528+
test('throws without a build volume while centering the controls', () => {
529+
// Current behavior: the constructor dereferences this._buildVolume
530+
// unconditionally when aiming the controls, so a missing buildVolume
531+
// option fails construction. If this starts passing, the constructor
532+
// learned to handle it and this test should assert the new behavior.
533+
const canvas = document.createElement('canvas');
534+
expect(() => new SceneManager({ canvas }, createJob())).toThrow(TypeError);
535+
});
536+
510537
test('applies every optional setting', () => {
511538
const configured = createSceneManager({
512539
backgroundColor: '#101010',

0 commit comments

Comments
 (0)