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:
parent
3b98e36914
commit
6305e83830
2 changed files with 13 additions and 1 deletions
|
@ -90,7 +90,7 @@ function setupWebGl(canvas: HTMLCanvasElement | null, isDarkMode: boolean) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CulledShapes() {
|
function _CulledShapes() {
|
||||||
const editor = useEditor()
|
const editor = useEditor()
|
||||||
const isDarkMode = useIsDarkMode()
|
const isDarkMode = useIsDarkMode()
|
||||||
const canvasRef = useRef<HTMLCanvasElement>(null)
|
const canvasRef = useRef<HTMLCanvasElement>(null)
|
||||||
|
@ -177,3 +177,10 @@ export function CulledShapes() {
|
||||||
<canvas ref={canvasRef} className="tl-culled-shapes__canvas" />
|
<canvas ref={canvasRef} className="tl-culled-shapes__canvas" />
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function CulledShapes() {
|
||||||
|
if (process.env.NODE_ENV === 'test') {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return _CulledShapes()
|
||||||
|
}
|
||||||
|
|
|
@ -179,6 +179,11 @@ function usePattern() {
|
||||||
const [backgroundUrls, setBackgroundUrls] = useState<PatternDef[]>(defaultPatterns)
|
const [backgroundUrls, setBackgroundUrls] = useState<PatternDef[]>(defaultPatterns)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (process.env.NODE_ENV === 'test') {
|
||||||
|
setIsReady(true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const promises: Promise<{ zoom: number; url: string; darkMode: boolean }>[] = []
|
const promises: Promise<{ zoom: number; url: string; darkMode: boolean }>[] = []
|
||||||
|
|
||||||
for (let i = 1; i <= Math.ceil(MAX_ZOOM); i++) {
|
for (let i = 1; i <= Math.ceil(MAX_ZOOM); i++) {
|
||||||
|
|
Loading…
Reference in a new issue