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
13380e79
Commit
13380e79
authored
1 year ago
by
Viivi Nevalainen
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
aa02bf8d
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_backend/tests/list_helper.test.js
+94
-0
94 additions, 0 deletions
bloglist_backend/tests/list_helper.test.js
with
94 additions
and
0 deletions
bloglist_backend/tests/list_helper.test.js
0 → 100644
+
94
−
0
View file @
13380e79
const
listHelper
=
require
(
'
../utils/list_helper
'
)
//dummy-testi, palauttaa aina 1 ja saa parametriksi blogilistan
describe
(
'
dummy
'
,
()
=>
{
test
(
'
dummy returns one
'
,
()
=>
{
const
blogs
=
[]
const
result
=
listHelper
.
dummy
(
blogs
)
expect
(
result
).
toBe
(
1
)
})
})
describe
(
'
total likes
'
,
()
=>
{
//testi tyhjälle listalle, palauttaa nollan
test
(
'
of empty list is zero
'
,
()
=>
{
const
emptyList
=
[]
const
result
=
listHelper
.
totalLikes
(
emptyList
)
expect
(
result
).
toBe
(
0
)
})
//testi listalle, jossa yksi blogi, palauttaa kyseisen tykkäysmäärän
test
(
'
when list has only one blog equals the likes of that
'
,
()
=>
{
const
listWithOneBlog
=
[
{
_id
:
'
5a422aa71b54a676234d17f8
'
,
title
:
'
Go To Statement Considered Harmful
'
,
author
:
'
Edsger W. Dijkstra
'
,
url
:
'
http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html
'
,
likes
:
5
,
__v
:
0
}
]
const
result
=
listHelper
.
totalLikes
(
listWithOneBlog
)
expect
(
result
).
toBe
(
5
)
})
//testi isolle listalle, palauttaa tykkäysten summan
test
(
'
of a bigger list is calculated right
'
,
()
=>
{
const
bigList
=
[
{
_id
:
"
5a422a851b54a676234d17f7
"
,
title
:
"
React patterns
"
,
author
:
"
Michael Chan
"
,
url
:
"
https://reactpatterns.com/
"
,
likes
:
7
,
__v
:
0
},
{
_id
:
"
5a422aa71b54a676234d17f8
"
,
title
:
"
Go To Statement Considered Harmful
"
,
author
:
"
Edsger W. Dijkstra
"
,
url
:
"
http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html
"
,
likes
:
5
,
__v
:
0
},
{
_id
:
"
5a422b3a1b54a676234d17f9
"
,
title
:
"
Canonical string reduction
"
,
author
:
"
Edsger W. Dijkstra
"
,
url
:
"
http://www.cs.utexas.edu/~EWD/transcriptions/EWD08xx/EWD808.html
"
,
likes
:
12
,
__v
:
0
},
{
_id
:
"
5a422b891b54a676234d17fa
"
,
title
:
"
First class tests
"
,
author
:
"
Robert C. Martin
"
,
url
:
"
http://blog.cleancoder.com/uncle-bob/2017/05/05/TestDefinitions.htmll
"
,
likes
:
10
,
__v
:
0
},
{
_id
:
"
5a422ba71b54a676234d17fb
"
,
title
:
"
TDD harms architecture
"
,
author
:
"
Robert C. Martin
"
,
url
:
"
http://blog.cleancoder.com/uncle-bob/2017/03/03/TDD-Harms-Architecture.html
"
,
likes
:
0
,
__v
:
0
},
{
_id
:
"
5a422bc61b54a676234d17fc
"
,
title
:
"
Type wars
"
,
author
:
"
Robert C. Martin
"
,
url
:
"
http://blog.cleancoder.com/uncle-bob/2016/05/01/TypeWars.html
"
,
likes
:
2
,
__v
:
0
}
]
const
result
=
listHelper
.
totalLikes
(
bigList
)
expect
(
result
).
toBe
(
36
)
})
})
\ 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