Skip to content

Commit

Permalink
chore(tests): add pierced props invalidation case
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett committed Oct 11, 2022
1 parent af08492 commit 1205150
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/fiber/tests/core/renderer.test.tsx
Expand Up @@ -762,4 +762,26 @@ describe('renderer', () => {
expect(groupHandle).toBeDefined()
expect(prevUUID).not.toBe(groupHandle!.uuid)
})

it('invalidates pierced props when root is changed', async () => {
const material = React.createRef<THREE.MeshBasicMaterial>()
const texture1 = { needsUpdate: false, name: '' } as THREE.Texture
const texture2 = { needsUpdate: false, name: '' } as THREE.Texture

await act(async () =>
root.render(<meshBasicMaterial ref={material} map={texture1} map-needsUpdate={true} map-name="test" />),
)

expect(material.current!.map).toBe(texture1)
expect(texture1.needsUpdate).toBe(true)
expect(texture1.name).toBe('test')

await act(async () =>
root.render(<meshBasicMaterial ref={material} map={texture2} map-needsUpdate={true} map-name="test" />),
)

expect(material.current!.map).toBe(texture2)
expect(texture2.needsUpdate).toBe(true)
expect(texture2.name).toBe('test')
})
})

0 comments on commit 1205150

Please sign in to comment.