Skip to content

Commit

Permalink
Use async client components
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-sherman committed May 16, 2023
1 parent df4409b commit 9e4aa67
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 59 deletions.
54 changes: 0 additions & 54 deletions app/serverRender.ts

This file was deleted.

19 changes: 14 additions & 5 deletions app/test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { screen } from '@testing-library/react'
import { screen, render, waitFor } from '@testing-library/react'
import Layout from './layout'
import Page from './page'
import serverRender from './serverRender'
import { Suspense } from 'react'

beforeEach(() => serverRender(<Page />, { wrapper: Layout }))
beforeEach(() =>
render(
<Suspense fallback={<p>Loading...</p>}>
<Layout>
<Page />
</Layout>
</Suspense>
)
)

test.each(['client', 'server', 'layout'])(`%s component`, (keyword) => {
expect(screen.getByText(keyword)).toBeInTheDocument()
test.each(['client', 'server', 'layout'])(`%s component`, async (keyword) => {
expect(screen.getByText('Loading...')).toBeInTheDocument()
await waitFor(() => expect(screen.getByText(keyword)).toBeInTheDocument())
})

0 comments on commit 9e4aa67

Please sign in to comment.