This repository has been archived on 2025-12-11. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
fullstack-open/part4/bloglist/tests/test_helper.js
Andrew Trieu 1c781aca74 Upload 4.9
2023-05-31 20:55:51 +03:00

45 lines
759 B
JavaScript

const Blog = require('../models/blog')
const initialBlogs = [
{
title: 'My blog',
author: 'Andrew',
url: 'www.andrew.eu',
likes: 1000,
},
{
title: 'My blog 2',
author: 'Andrew',
url: 'www.andrew.eu',
likes: 3000,
},
{
title: 'Another blog',
author: 'Hans',
url: 'www.andrew.eu',
likes: 5000,
}
]
const nonExistingId = async () => {
const blog = new Blog({
title: 'Test',
author: 'tester',
url: 'www.test.eu',
likes: 999,
})
await blog.save()
await blog.deleteOne()
return blog._id.toString()
}
const blogsInDb = async () => {
const blogs = await Blog.find({})
return blogs.map(blog => blog.toJSON())
}
module.exports = {
initialBlogs, nonExistingId, blogsInDb
}