{"size": 1327, "ext": "js", "max_stars_repo_path": "09/Source/Serverless/test/users/users_remove.test.js", "max_stars_repo_name": "renancaraujo/2019", "max_stars_repo_stars_event_min_datetime": "2019-09-03T16:24:27.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-12T15:33:29.000Z", "max_issues_repo_path": "09/Source/Serverless/test/users/users_remove.test.js", "max_issues_repo_name": "renancaraujo/2019", "max_issues_repo_issues_event_min_datetime": "2019-09-16T13:52:30.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-10T12:00:39.000Z", "max_forks_repo_path": "09/Source/Serverless/test/users/users_remove.test.js", "max_forks_repo_name": "renancaraujo/2019", "max_forks_repo_forks_event_min_datetime": "2019-10-05T07:11:06.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-13T01:06:37.000Z"}
{"max_stars_count": 21, "max_issues_count": 4, "max_forks_count": 3, "avg_line_length": 28.2340425532, "max_line_length": 123, "alphanum_fraction": 0.5855312735}
require('dotenv').config()
const mongodb = require('./../../lib/mongodb')
const { ObjectId } = require('mongodb')
const usersRemove = require('./../../functions/users/users_remove')

const collectionUsers = 'users'

describe('users/users_remove.js', () => {
  beforeAll(async () => {
    try {
      await mongodb.connect()
      await mongodb(collectionUsers).insertOne({ email: 'removetest@test.com', _id: ObjectId('5c326feaf8a79d378757bed0') })
    } catch (error) {
      console.log('error -> ', error)
    }
  })
  afterAll(async () => {
    try {
      await mongodb(collectionUsers).removeOne({ email: 'removetest@test.com' })
    } catch (error) {
      console.log('error -> ', error)
    }
  })
  describe('Should success', () => {
    it('valid code user', async () => {
      const event = {}
      const res = await usersRemove(event)
      expect(res.statusCode).toBe(400)
    })
    it('remove user', async () => {
      const event = {
        body: JSON.stringify({
          _id: '5c326feaf8a79d378757bed0'
        })
      }
      const res = await usersRemove(event)
      expect(res.statusCode).toBe(200)
    })
  })
  describe('Should fail', () => {
    it('should return an error event not send', async () => {
      const res = await usersRemove()
      expect(res.statusCode).toBe(400)
    })
  })
})
