Fix some tests (#3403)

This PR fixes some jest test.

- We skip the culling shapes in test environments.
- We skip rendering patterns in test environments.

### Change Type

- [x] `sdk` — Changes the tldraw SDK
- [x] `tests` — Changes to any test code
This commit is contained in:
Steve Ruiz 2024-04-09 16:42:54 +01:00 committed by GitHub
parent 3b98e36914
commit 6305e83830
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -90,7 +90,7 @@ function setupWebGl(canvas: HTMLCanvasElement | null, isDarkMode: boolean) {
}
}
export function CulledShapes() {
function _CulledShapes() {
const editor = useEditor()
const isDarkMode = useIsDarkMode()
const canvasRef = useRef<HTMLCanvasElement>(null)
@ -177,3 +177,10 @@ export function CulledShapes() {
<canvas ref={canvasRef} className="tl-culled-shapes__canvas" />
) : null
}
export function CulledShapes() {
if (process.env.NODE_ENV === 'test') {
return null
}
return _CulledShapes()
}

View file

@ -179,6 +179,11 @@ function usePattern() {
const [backgroundUrls, setBackgroundUrls] = useState<PatternDef[]>(defaultPatterns)
useEffect(() => {
if (process.env.NODE_ENV === 'test') {
setIsReady(true)
return
}
const promises: Promise<{ zoom: number; url: string; darkMode: boolean }>[] = []
for (let i = 1; i <= Math.ceil(MAX_ZOOM); i++) {