renamed
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
const listHelper = require("../utils/list_helper");
|
||||
|
||||
test("dummy returns one", () => {
|
||||
const blogs = [];
|
||||
const result = listHelper.dummy(blogs);
|
||||
expect(result).toBe(1);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
const listHelper = require("../utils/list_helper");
|
||||
|
||||
describe("total likes", () => {
|
||||
const blogs = [
|
||||
{
|
||||
_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,
|
||||
},
|
||||
];
|
||||
test('testing likes',()=>{
|
||||
const result= listHelper.totalLikes(blogs)
|
||||
expect(result).toBe(36)
|
||||
})
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
const listHelper = require("../utils/list_helper");
|
||||
|
||||
describe("maxLikes", () => {
|
||||
const blogs = [
|
||||
{
|
||||
_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,
|
||||
},
|
||||
];
|
||||
test("most Liked Blog", () => {
|
||||
const result = listHelper.favoriteBlog(blogs);
|
||||
expect(result).toBe(7);
|
||||
});
|
||||
test("most Blogs", () => {
|
||||
const result = listHelper.mostBlogs(blogs);
|
||||
expect(result).toBe(3);
|
||||
});
|
||||
test("most Liked author", () => {
|
||||
const result = listHelper.mostLikes(blogs);
|
||||
expect(result).toBe(17);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
const mongoose = require('mongoose')
|
||||
const supertest = require('supertest')
|
||||
const app = require('../app')
|
||||
|
||||
const api = supertest(app)
|
||||
|
||||
test('blogs are returned as json', async () => {
|
||||
await api
|
||||
.get('/api/blogs')
|
||||
.expect(200)
|
||||
.expect('Content-Type', /application\/json/)
|
||||
})
|
||||
test('blog is being posted',async()=>{
|
||||
await api.post('/api/blogs').send({title:'title2'})
|
||||
const response = await api.get('api/blogs')
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
await mongoose.connection.close()
|
||||
})
|
||||
Reference in New Issue
Block a user