`),
)
})
it('should render using the data-mount-in prop and take priority over a selector if passed', async () => {
const r = render(
,
)
await waitFor(() =>
expect(
within(r.getByTestId('selector')).queryByTestId('widget'),
).not.toBeInTheDocument(),
)
await waitFor(() =>
expect(
within(r.getByTestId('inlineScriptMountIn')).queryByTestId('widget'),
).toBeInTheDocument(),
)
})
it('should pass down default props', async () => {
const r = render()
const initialProps = {
apples: 'yes',
bananas: 1,
kiwis: true,
}
const island = createIsland(Widget)
island.render({
selector: '[data-island="island"]',
initialProps,
})
await waitFor(() =>
expect(r.getByTestId('widget').innerHTML).toEqual(
JSON.stringify({ ...initialProps, island: 'island' }),
),
)
})
it('should render twice if multiple nodes are found from the selector', async () => {
const r = render(
,
)
const initialProps = {
apples: 'yes',
bananas: 1,
kiwis: true,
}
const island = createIsland(Widget)
island.render({
selector: '[data-island="island"]',
initialProps,
})
// NOTE: Notice there is a different between this one and the other test.
// This one render inside of two data-island elements whereas the other
// renders twice inside of the same data widget host element!
await waitFor(() =>
expect(r.container).toMatchInlineSnapshot(`