import app from "./app"; import request from "supertest"; const note = { title: 'Test Note', text: 'This is a test note.' }; describe('PUT and GET methods of "/note" endpoint', () => { it('should create and return a note with PUT method', async () => { const res = await request(app).put('/note').send(note); expect(res.status).toBe(202); expect(res.body).toHaveProperty("note"); }); it('should return the created note with GET method', async () => { const res = await request(app).put('/note').send(note); const id = res.body["note"]; const res2 = await request(app).get(`/note/${id}`).send(note); expect(res2.status).toBe(200); expect(res2.body).toMatchObject({note: { ...note, id }}); }); });