const request = require("supertest") const { expect, describe, test, beforeAll, afterAll, } = require('@jest/globals'); const app = require("../src/index") const db = require("../src/models"); const { signupUser } = require("./data/user.test.data") describe("Test the root path", () => { beforeAll(() => { db.sequelize.sync({force: true}).then(() => { db.role.bulkCreate([ { name: 'user' }, { name: 'moderator' }, { name: 'administrator' }, ]); }) }); afterAll(async () => { try { await db.sequelize.close(); } catch (error) { console.error(error); process.exit(1); } }); test("It should response the GET method", done => { request(app) .get("/") .then(response => { expect(response.statusCode).toBe(200); done(); }); }); test("should signup a user", done => { request(app) .post("/api/auth/signup") .send(signupUser) .then( res => { console.log(JSON.stringify(res, null, 2)); expect(res.header['content-type']).toBe('application/json; charset=utf-8'); expect(res.statusCode).toBe(400); done(); }, error => { done(); }) }); }); // describe("GET /api/auth/signup", () => { // it("should signup a user", async () => { // return request(app) // .post("/api/auth/signup") // .send(signupUser) // .expect('Content-Type', /json/) // .expect(200) // .then((res) => { // expect(res.statusCode).toBe(200); // }) // }); // });