Skip to content

Commit

Permalink
Clarify difference between rendered element and container
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jan 27, 2021
1 parent d918b3f commit b9836da
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions types/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {render, fireEvent, screen, waitFor} from '.'
import * as pure from './pure'

export async function testRender() {
const page = render(<div />)
const page = render(<button />)

// single queries
page.getByText('foo')
Expand All @@ -22,7 +22,7 @@ export async function testRender() {
}

export async function testPureRender() {
const page = pure.render(<div />)
const page = pure.render(<button />)

// single queries
page.getByText('foo')
Expand All @@ -43,8 +43,9 @@ export async function testPureRender() {
export function testRenderOptions() {
const container = document.createElement('div')
const options = {container}
const {container: returnedContainer} = render(<div />, options)
// Unclear why TypeScript infers `HTMLElement` here when the the input `container` is `HTMLDivElement`
const {container: returnedContainer} = render(<button />, options)
// Unclear why TypeScript infers `HTMLElement` here when the the input `container` is `HTMLDivElement`.
// It's working for `testSVGRenderOptions`.
// Hopefully this breaks someday and we can switch to
// expectType<HTMLDivElement, typeof returnedContainer>(returnedContainer)
expectType<HTMLElement, typeof returnedContainer>(returnedContainer)
Expand All @@ -56,7 +57,7 @@ export function testSVGRenderOptions() {
'svg',
)
const options = {container}
const {container: returnedContainer} = render(<svg />, options)
const {container: returnedContainer} = render(<path />, options)
expectType<SVGSVGElement, typeof returnedContainer>(returnedContainer)
}

Expand Down

0 comments on commit b9836da

Please sign in to comment.