import '@testing-library/jest-dom'
import { fireEvent, render, screen } from '@testing-library/react'
import React from 'react'
import tunnel from '../src'
describe('tunnelrat', () => {
it('transports the children of In into Out', () => {
const t = tunnel()
const Outlet = () => (
`)
})
it('retains the expected order of multiple children after un- and remounts', () => {
const t = tunnel()
const Rat = ({ name }: { name: string }) => {
const [visible, setVisible] = React.useState(true)
return (
`)
/* Remove the middle rat */
fireEvent.click(screen.getByText('Toggle Two'))
expect(container).toMatchInlineSnapshot(`
One
Three
`)
/* Re-add it */
fireEvent.click(screen.getByText('Toggle Two'))
/* The "Two" rat gets re-added, and at the top of the list. */
expect(container).toMatchInlineSnapshot(`