Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bloglist
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Maintenance moved to Monday 17.3. at 13:00. ETA 60 - 90 minutes.
Show more breadcrumbs
Viivi Nevalainen
bloglist
Commits
be39fc50
Commit
be39fc50
authored
1 year ago
by
Viivi Nevalainen
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
3e3a73fb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bloglist_frontend/src/components/BlogForm.test.js
+30
-0
30 additions, 0 deletions
bloglist_frontend/src/components/BlogForm.test.js
with
30 additions
and
0 deletions
bloglist_frontend/src/components/BlogForm.test.js
0 → 100644
+
30
−
0
View file @
be39fc50
import
React
from
'
react
'
import
'
@testing-library/jest-dom/extend-expect
'
import
{
render
,
screen
}
from
'
@testing-library/react
'
import
userEvent
from
'
@testing-library/user-event
'
import
BlogForm
from
'
./BlogForm
'
test
(
'
<BlogForm /> calls propsfunction when blog is created
'
,
async
()
=>
{
const
addBlog
=
jest
.
fn
()
render
(
<
BlogForm
createBlog
=
{
addBlog
}
/>
)
const
titleInput
=
screen
.
getByPlaceholderText
(
'
write title here
'
)
const
authorInput
=
screen
.
getByPlaceholderText
(
'
write author here
'
)
const
urlInput
=
screen
.
getByPlaceholderText
(
'
write url here
'
)
await
userEvent
.
type
(
titleInput
,
'
Test title
'
)
await
userEvent
.
type
(
authorInput
,
'
Test author
'
)
await
userEvent
.
type
(
urlInput
,
'
http://example.com
'
)
const
submitButton
=
screen
.
getByText
(
'
create
'
)
await
userEvent
.
click
(
submitButton
)
expect
(
addBlog
).
toHaveBeenCalledTimes
(
1
)
expect
(
addBlog
).
toHaveBeenCalledWith
({
title
:
'
Test title
'
,
author
:
'
Test author
'
,
url
:
'
http://example.com
'
,
likes
:
0
})
})
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment