Skip to content

Commit

Permalink
solution 4.10: Blog list tests, step3
Browse files Browse the repository at this point in the history
  • Loading branch information
patchamama committed Sep 10, 2023
1 parent 6b99032 commit d9fe5ba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ npm test
## b. Testing the backend

- [Exercises 4.8.-4.12.](https://fullstackopen.com/es/part4/probando_el_backend#ejercicios-4-8-4-12)
_Details solutions: [4.8](https://github.com/patchamama/fullstackopen-part4-bloglist/commit/f4361d4a4973e98d2368596056f9257e1487565d) | [4.9]() | [4.10]() | [4.11]() | [4.12]()_
_Details solutions: [4.8](https://github.com/patchamama/fullstackopen-part4-bloglist/commit/f4361d4a4973e98d2368596056f9257e1487565d) | [4.9](https://github.com/patchamama/fullstackopen-part4-bloglist/commit/6b9903229f75ed7def60d4f81a386e61997a9341) | [4.10]() | [4.11]() | [4.12]()_

## c. User administration

Expand Down
22 changes: 22 additions & 0 deletions tests/note_api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,28 @@ test('unknown endpoint in api url', async () => {
expect(response.body.error).toBe('unknown endpoint')
})

test('a valid blog can be added', async () => {
const newBlog = {
title: 'Fugas o la ansiedad de sentirse vivo',
author: 'A. Pacheco',
url: 'https://unlibroenmimochila.blogspot.com/2017/12/fugas-o-la-ansiedad-de-sentirse-vivo.html',
likes: 4,
}

await api
.post('/api/blogs')
.send(newBlog)
.expect(201)
.expect('Content-Type', /application\/json/)

const response = await api.get('/api/blogs')

const contents = response.body.map((r) => r.title)

expect(response.body).toHaveLength(initialBlogs.length + 1)
expect(contents).toContain('Fugas o la ansiedad de sentirse vivo')
})

test('unique identifier property of the blog posts is named id,', async () => {
const response = await api.get('/api/blogs')
const contents = response.body[0]
Expand Down

0 comments on commit d9fe5ba

Please sign in to comment.