2020-04-09 17:53:48 +02:00
|
|
|
const supertest = require("supertest");
|
|
|
|
const app = require("../../../../app");
|
2020-04-20 17:17:11 +02:00
|
|
|
const { createClientDatabase, destroyDatabase } = require("./couchTestUtils");
|
2020-04-09 17:53:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
const CLIENT_DB_ID = "client-testing";
|
|
|
|
|
|
|
|
describe("/applications", () => {
|
|
|
|
let request;
|
2020-04-13 17:22:30 +02:00
|
|
|
let server;
|
2020-04-09 17:53:48 +02:00
|
|
|
|
|
|
|
beforeAll(async () => {
|
2020-04-13 17:22:30 +02:00
|
|
|
server = await app({
|
2020-04-09 17:53:48 +02:00
|
|
|
config: {
|
|
|
|
port: 3000
|
|
|
|
}
|
|
|
|
});
|
|
|
|
request = supertest(server);
|
2020-04-13 17:22:30 +02:00
|
|
|
await createClientDatabase();
|
2020-04-09 17:53:48 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
2020-04-20 17:17:11 +02:00
|
|
|
await destroyDatabase(CLIENT_DB_ID)
|
2020-04-13 17:22:30 +02:00
|
|
|
server.close();
|
2020-04-09 17:53:48 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
describe("create", () => {
|
|
|
|
it("returns a success message when the application is successfully created", done => {
|
|
|
|
request
|
|
|
|
.post("/api/testing/applications")
|
|
|
|
.send({ name: "My App" })
|
|
|
|
.set("Accept", "application/json")
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect(200)
|
|
|
|
.end((err, res) => {
|
|
|
|
expect(res.body.message).toEqual("Application My App created successfully");
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|