Skip to content

Commit

Permalink
Issue #3 added a test for lights
Browse files Browse the repository at this point in the history
  • Loading branch information
thompson318 committed May 4, 2022
1 parent dd83eb0 commit 78e1a68
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lights.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import vtkLight from '@kitware/vtk.js/Rendering/Core/Light.js'

export function setupLights (url, renderer) {
const spotLightOn = url.searchParams.get('spotlight')
if (spotLightOn != null) {
if (spotLightOn !== null) {
const light0 = vtkLight.newInstance()
light0.setLightTypeToSceneLight()
light0.setFocalPoint(150, 0, 0)
Expand Down
22 changes: 22 additions & 0 deletions src/test/lights.test.Spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import vtkRenderer from '@kitware/vtk.js/Rendering/Core/Renderer.js'
import { setupLights } from '../lights.js';

describe('Set up Lights Test', () => {
const rendererns = vtkRenderer.newInstance()
const urlns = new URL('https://test.com?nospjjotlight')
const lightsBefore = rendererns.getLights().length
it('should run without spotlight', () => {
setupLights (urlns, rendererns)
const lightsAfter = rendererns.getLights().length
console.log(lightsBefore + ' : ' + lightsAfter)
expect(lightsAfter).toBe(lightsBefore)
});

const url = new URL('https://test.com?spotlight')
const renderer = vtkRenderer.newInstance()
const lightsBeforeSpot = renderer.getLights().length
it('should add a spotlight', () => {
setupLights (url, renderer)
expect(renderer.getLights().length).toBe(lightsBeforeSpot + 1)
});
});

0 comments on commit 78e1a68

Please sign in to comment.