mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
* used createRoot in test * Removed unused test
This commit is contained in:
parent
af607edf9a
commit
75d0886cd6
@ -5,7 +5,7 @@ import {
|
||||
useLayoutEffect,
|
||||
useState,
|
||||
} from 'react'
|
||||
import { act, fireEvent, render, waitFor } from '@testing-library/react'
|
||||
import { act, fireEvent, render } from '@testing-library/react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import create, { StoreApi } from 'zustand'
|
||||
|
||||
@ -143,25 +143,6 @@ it('only re-renders if selected state has changed', async () => {
|
||||
expect(controlRenderCount).toBe(1)
|
||||
})
|
||||
|
||||
it('re-renders with useLayoutEffect', async () => {
|
||||
const useBoundStore = create(() => ({ state: false }))
|
||||
|
||||
function Component() {
|
||||
const { state } = useBoundStore()
|
||||
useLayoutEffect(() => {
|
||||
useBoundStore.setState({ state: true })
|
||||
}, [])
|
||||
return <>{`${state}`}</>
|
||||
}
|
||||
|
||||
const container = document.createElement('div')
|
||||
ReactDOM.render(<Component />, container)
|
||||
await waitFor(() => {
|
||||
expect(container.innerHTML).toBe('true')
|
||||
})
|
||||
ReactDOM.unmountComponentAtNode(container)
|
||||
})
|
||||
|
||||
it('can batch updates', async () => {
|
||||
const useBoundStore = create<CounterState>((set) => ({
|
||||
count: 0,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user