const { describe, it, expect } = require('@jest/globals')
const request = require('supertest')
const express = require('express')
const mockingoose = require('mockingoose')
const { ListModel } = require('../data/model/todo/list')

const todo = require('../routers/todo/routes')

const app = express()
app.use(todo)

const listExample = {
  "title": "qqq",
  "items": [],
  "_id": "670f69b5796ce7a9069da2f7",
  "created": "2024-10-16T07:22:29.042Z",
  "id": "670f69b5796ce7a9069da2f7"
}

describe('todo list app', () => {
  it('get list', (done) => {
    mockingoose(ListModel)
    .toReturn([listExample], 'find')
    .toReturn(listExample, 'create')

    request(app)
      .get('/list')
      .expect(200)
      .then((response) => {
        expect(response.body).toMatchSnapshot()
        done()
      })
  })
})
