import supertest from "supertest" import app from "../../server" import { Product } from '../../models/product' const token = process.env.TOKEN_SECRET_TEST as string const request = supertest(app); const testProduct: Product = { name: "metro", price: 10 } const updatedProduct: Product = { name: "1984", price: 5 } describe("Product handler", () => { console.log("PRODUCT") it('Should create a new product', async () => { const response = await request .post("/products") .auth(token, { type: "bearer" }) .send(testProduct); expect(response.status).toBe(200); }) it('Should index products', async () => { const response = await request .get("/products") expect(response.status).toBe(200); }) it('Should get product by id', async () => { const response = await request .get("/products/1") expect(response.status).toBe(200); }) it('Should update product with id', async () => { const response = await request .put("/products/1") .auth(token, { type: 'bearer'}) .send(updatedProduct) expect(response.status).toBe(200); }) it('Should delete product with id', async () => { const response = await request .delete("/products/1") .auth(token, { type: 'bearer'}) expect(response.status).toBe(200); }) })