Skip to content

Commit

Permalink
Update atomWithObservable.test.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi authored Sep 2, 2023
1 parent 7719cf3 commit 3e5b68a
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions tests/react/vanilla-utils/atomWithObservable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,54 +130,6 @@ it('writable count state without initial value', async () => {
await findByText('count: 3')
})

// See: https://github.com/pmndrs/jotai/discussions/2007
it('writable count state without initial value and rxjs chain', async () => {
const single$ = new Subject<number>()
const double$ = single$.pipe(map((n) => n * 2))
const singleAtom = atomWithObservable(() => single$)
const doubleAtom = atomWithObservable(() => double$)

// THIS WORKS:
// const singleAndDoubleAtom = atom((get) =>
// Promise.all([get(singleAtom), get(doubleAtom)])
// )

// in CounterValue:
// const [single, double] = useAtomValue(singleAndDoubleAtom)

const CounterValue = () => {
const single = useAtomValue(singleAtom)
const double = useAtomValue(doubleAtom)

return (
<>
single: {single}, double: {double}
</>
)
}

const CounterButton = () => {
return <button onClick={() => single$.next(2)}>button</button>
}

const { findByText, getByText } = render(
<StrictMode>
<Suspense fallback="loading">
<CounterValue />
</Suspense>
<CounterButton />
</StrictMode>
)

await findByText('loading')

fireEvent.click(getByText('button'))
await findByText('single: 2, double: 4')

act(() => single$.next(3))
await findByText('single: 3, double: 6')
})

it('writable count state with delayed value', async () => {
const subject = new Subject<number>()
const observableAtom = atomWithObservable(() => {
Expand Down

0 comments on commit 3e5b68a

Please sign in to comment.