budibase/packages/server/middleware/routes/neo/tests/user.spec.js

41 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-04-09 17:53:48 +02:00
const couchdb = require("../../../../db");
const supertest = require("supertest");
const app = require("../../../../app");
const { createInstanceDatabase } = require("./couchTestUtils");
const TEST_INSTANCE_ID = "testing-123";
describe("/users", () => {
let request;
beforeAll(async () => {
const server = await app({
config: {
port: 3000
}
});
request = supertest(server);
2020-04-10 12:18:15 +02:00
createInstanceDatabase(TEST_INSTANCE_ID);
2020-04-09 17:53:48 +02:00
});
afterAll(async () => {
app.close();
})
describe("create", () => {
2020-04-10 12:18:15 +02:00
it("returns a success message when a user is successfully created", done => {
2020-04-09 17:53:48 +02:00
request
2020-04-10 12:18:15 +02:00
.post(`/api/${TEST_INSTANCE_ID}/users`)
.send({ name: "John" })
2020-04-09 17:53:48 +02:00
.set("Accept", "application/json")
.expect('Content-Type', /json/)
.expect(200)
.end(async (err, res) => {
expect(res.body.message).toEqual("Instance Database testing-123 successfully provisioned.");
done();
});
})
});
});