Update tests
This commit is contained in:
@@ -3,7 +3,7 @@ import Article from './Article'
|
|||||||
export const generated = () => {
|
export const generated = () => {
|
||||||
return (
|
return (
|
||||||
<Article
|
<Article
|
||||||
post={{
|
article={{
|
||||||
id: 1,
|
id: 1,
|
||||||
title: 'First Post',
|
title: 'First Post',
|
||||||
body:
|
body:
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ import Article from './Article'
|
|||||||
|
|
||||||
describe('Article', () => {
|
describe('Article', () => {
|
||||||
it('renders a blog post', () => {
|
it('renders a blog post', () => {
|
||||||
const post = {
|
const article = {
|
||||||
id: 1,
|
id: 1,
|
||||||
title: 'First post',
|
title: 'First post',
|
||||||
body: `Neutra tacos hot chicken prism raw denim, put a bird on it enamel pin post-ironic vape cred DIY. Street art next level umami squid. Hammock hexagon glossier 8-bit banjo. Neutra la croix mixtape echo park four loko semiotics kitsch forage chambray. Semiotics salvia selfies jianbing hella shaman. Letterpress helvetica vaporware cronut, shaman butcher YOLO poke fixie hoodie gentrify woke heirloom.`,
|
body: `Neutra tacos hot chicken prism raw denim, put a bird on it enamel pin post-ironic vape cred DIY. Street art next level umami squid. Hammock hexagon glossier 8-bit banjo. Neutra la croix mixtape echo park four loko semiotics kitsch forage chambray. Semiotics salvia selfies jianbing hella shaman. Letterpress helvetica vaporware cronut, shaman butcher YOLO poke fixie hoodie gentrify woke heirloom.`,
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
}
|
}
|
||||||
render(<Article post={post} />)
|
render(<Article article={article} />)
|
||||||
|
|
||||||
expect(screen.getByText(post.title)).toBeInTheDocument()
|
expect(screen.getByText(article.title)).toBeInTheDocument()
|
||||||
expect(screen.getByText(post.body)).toBeInTheDocument()
|
expect(screen.getByText(article.body)).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ describe('ArticleCell', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('Success renders successfully', async () => {
|
test('Success renders successfully', async () => {
|
||||||
const post = standard().post
|
const article = standard().post
|
||||||
render(<Success post={post} />)
|
render(<Success article={article} />)
|
||||||
|
|
||||||
expect(screen.getByText(post.title)).toBeInTheDocument()
|
expect(screen.getByText(article.title)).toBeInTheDocument()
|
||||||
expect(screen.getByText(post.body)).toBeInTheDocument()
|
expect(screen.getByText(article.body)).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ describe('ArticlesCell', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('Success renders successfully', async () => {
|
test('Success renders successfully', async () => {
|
||||||
const posts = standard().posts
|
const articles = standard().posts
|
||||||
render(<Success posts={posts} />)
|
render(<Success articles={articles} />)
|
||||||
|
|
||||||
expect(screen.getByText(posts[0].title)).toBeInTheDocument()
|
expect(screen.getByText(articles[0].title)).toBeInTheDocument()
|
||||||
expect(screen.getByText(posts[0].body)).toBeInTheDocument()
|
expect(screen.getByText(articles[0].body)).toBeInTheDocument()
|
||||||
expect(screen.getByText(posts[1].title)).toBeInTheDocument()
|
expect(screen.getByText(articles[1].title)).toBeInTheDocument()
|
||||||
expect(screen.getByText(posts[1].body)).toBeInTheDocument()
|
expect(screen.getByText(articles[1].body)).toBeInTheDocument()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,18 +11,18 @@ const loggedOut = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('BlogLayout', () => {
|
describe('BlogLayout', () => {
|
||||||
it('displays a Log In link when not logged in', async () => {
|
it('displays a Login link when not logged in', async () => {
|
||||||
loggedOut()
|
loggedOut()
|
||||||
render(<BlogLayout />)
|
render(<BlogLayout />)
|
||||||
|
|
||||||
await waitFor(() => expect(screen.getByText('Log In')).toBeInTheDocument())
|
await waitFor(() => expect(screen.getByText('Login')).toBeInTheDocument())
|
||||||
})
|
})
|
||||||
|
|
||||||
it('displays a Log Out link when logged in', async () => {
|
it('displays a Logout link when logged in', async () => {
|
||||||
loggedIn()
|
loggedIn()
|
||||||
render(<BlogLayout />)
|
render(<BlogLayout />)
|
||||||
|
|
||||||
await waitFor(() => expect(screen.getByText('Log Out')).toBeInTheDocument())
|
await waitFor(() => expect(screen.getByText('Logout')).toBeInTheDocument())
|
||||||
})
|
})
|
||||||
|
|
||||||
it("displays a logged in user's email address", async () => {
|
it("displays a logged in user's email address", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user