|
|
@ -2,14 +2,17 @@ const { checkBuilderEndpoint } = require("./utilities/TestFunctions") |
|
|
const { basicQuery } = require("./utilities/structures") |
|
|
const { basicQuery } = require("./utilities/structures") |
|
|
const setup = require("./utilities") |
|
|
const setup = require("./utilities") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe("/queries", () => { |
|
|
describe("/queries", () => { |
|
|
let request = setup.getRequest() |
|
|
let request = setup.getRequest() |
|
|
let config = setup.getConfig() |
|
|
let config = setup.getConfig() |
|
|
|
|
|
let datasource |
|
|
|
|
|
|
|
|
afterAll(setup.afterAll) |
|
|
afterAll(setup.afterAll) |
|
|
|
|
|
|
|
|
beforeEach(async () => { |
|
|
beforeEach(async () => { |
|
|
await config.init() |
|
|
await config.init() |
|
|
|
|
|
datasource = await config.createDatasource() |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
describe("create", () => { |
|
|
describe("create", () => { |
|
|
@ -35,16 +38,6 @@ describe("/queries", () => { |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
describe("fetch", () => { |
|
|
describe("fetch", () => { |
|
|
let datasource |
|
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => { |
|
|
|
|
|
datasource = await config.createDatasource() |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
afterEach(() => { |
|
|
|
|
|
delete datasource._rev |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it("returns all the queries from the server", async () => { |
|
|
it("returns all the queries from the server", async () => { |
|
|
const query = await config.createQuery() |
|
|
const query = await config.createQuery() |
|
|
const res = await request |
|
|
const res = await request |
|
|
@ -73,17 +66,33 @@ describe("/queries", () => { |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
describe("destroy", () => { |
|
|
describe("find", () => { |
|
|
let datasource |
|
|
it("should find a query in builder", async () => { |
|
|
|
|
|
const query = await config.createQuery() |
|
|
beforeEach(async () => { |
|
|
const res = await request |
|
|
datasource = await config.createDatasource() |
|
|
.get(`/api/queries/${query._id}`) |
|
|
|
|
|
.set(config.defaultHeaders()) |
|
|
|
|
|
.expect("Content-Type", /json/) |
|
|
|
|
|
.expect(200) |
|
|
|
|
|
expect(res.body._id).toEqual(query._id) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
afterEach(() => { |
|
|
it("should find a query in cloud", async () => { |
|
|
delete datasource._rev |
|
|
await setup.switchToCloudForFunction(async () => { |
|
|
|
|
|
const query = await config.createQuery() |
|
|
|
|
|
const res = await request |
|
|
|
|
|
.get(`/api/queries/${query._id}`) |
|
|
|
|
|
.set(await config.roleHeaders()) |
|
|
|
|
|
.expect("Content-Type", /json/) |
|
|
|
|
|
.expect(200) |
|
|
|
|
|
expect(res.body.fields).toBeUndefined() |
|
|
|
|
|
expect(res.body.parameters).toBeUndefined() |
|
|
|
|
|
expect(res.body.schema).toBeUndefined() |
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
describe("destroy", () => { |
|
|
it("deletes a query and returns a success message", async () => { |
|
|
it("deletes a query and returns a success message", async () => { |
|
|
const query = await config.createQuery() |
|
|
const query = await config.createQuery() |
|
|
|
|
|
|
|
|
@ -109,4 +118,12 @@ describe("/queries", () => { |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
describe("preview", () => { |
|
|
|
|
|
// TODO: need to mock out an integration with a test one and try this
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
describe("execute", () => { |
|
|
|
|
|
// TODO: need to mock out an integration with a test one and try this
|
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|