Fixing broken backend test cases.
This commit is contained in:
parent
0301290fda
commit
2938d3a92d
|
@ -37,7 +37,37 @@ describe("run misc tests", () => {
|
||||||
|
|
||||||
describe("test table utilities", () => {
|
describe("test table utilities", () => {
|
||||||
it("should be able to import a CSV", async () => {
|
it("should be able to import a CSV", async () => {
|
||||||
const table = await config.createTable()
|
const table = await config.createTable({
|
||||||
|
name: "table",
|
||||||
|
type: "table",
|
||||||
|
key: "name",
|
||||||
|
schema: {
|
||||||
|
a: {
|
||||||
|
type: "string",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
b: {
|
||||||
|
type: "string",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
c: {
|
||||||
|
type: "string",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
d: {
|
||||||
|
type: "string",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
const dataImport = {
|
const dataImport = {
|
||||||
csvString: "a,b,c,d\n1,2,3,4"
|
csvString: "a,b,c,d\n1,2,3,4"
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,6 +125,7 @@ describe("/rows", () => {
|
||||||
numberNull: number,
|
numberNull: number,
|
||||||
numberUndefined: number,
|
numberUndefined: number,
|
||||||
numberString: number,
|
numberString: number,
|
||||||
|
numberNumber: number,
|
||||||
datetimeEmptyString: datetime,
|
datetimeEmptyString: datetime,
|
||||||
datetimeNull: datetime,
|
datetimeNull: datetime,
|
||||||
datetimeUndefined: datetime,
|
datetimeUndefined: datetime,
|
||||||
|
|
|
@ -1,5 +1,25 @@
|
||||||
const setup = require("./utilities")
|
const setup = require("./utilities")
|
||||||
|
|
||||||
|
function priceTable() {
|
||||||
|
return {
|
||||||
|
name: "table",
|
||||||
|
type: "table",
|
||||||
|
key: "name",
|
||||||
|
schema: {
|
||||||
|
Price: {
|
||||||
|
type: "number",
|
||||||
|
constraints: {},
|
||||||
|
},
|
||||||
|
Category: {
|
||||||
|
type: "string",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
describe("/views", () => {
|
describe("/views", () => {
|
||||||
let request = setup.getRequest()
|
let request = setup.getRequest()
|
||||||
let config = setup.getConfig()
|
let config = setup.getConfig()
|
||||||
|
@ -13,7 +33,7 @@ describe("/views", () => {
|
||||||
|
|
||||||
describe("create", () => {
|
describe("create", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
table = await config.createTable()
|
table = await config.createTable(priceTable())
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns a success message when the view is successfully created", async () => {
|
it("returns a success message when the view is successfully created", async () => {
|
||||||
|
@ -83,7 +103,7 @@ describe("/views", () => {
|
||||||
|
|
||||||
describe("fetch", () => {
|
describe("fetch", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
table = await config.createTable()
|
table = await config.createTable(priceTable())
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns only custom views", async () => {
|
it("returns only custom views", async () => {
|
||||||
|
@ -105,7 +125,7 @@ describe("/views", () => {
|
||||||
|
|
||||||
describe("query", () => {
|
describe("query", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
table = await config.createTable()
|
table = await config.createTable(priceTable())
|
||||||
})
|
})
|
||||||
|
|
||||||
it("returns data for the created view", async () => {
|
it("returns data for the created view", async () => {
|
||||||
|
@ -172,7 +192,7 @@ describe("/views", () => {
|
||||||
|
|
||||||
describe("destroy", () => {
|
describe("destroy", () => {
|
||||||
it("should be able to delete a view", async () => {
|
it("should be able to delete a view", async () => {
|
||||||
const table = await config.createTable()
|
const table = await config.createTable(priceTable())
|
||||||
const view = await config.createView()
|
const view = await config.createView()
|
||||||
const res = await request
|
const res = await request
|
||||||
.delete(`/api/views/${view.name}`)
|
.delete(`/api/views/${view.name}`)
|
||||||
|
@ -186,7 +206,7 @@ describe("/views", () => {
|
||||||
|
|
||||||
describe("exportView", () => {
|
describe("exportView", () => {
|
||||||
it("should be able to delete a view", async () => {
|
it("should be able to delete a view", async () => {
|
||||||
await config.createTable()
|
await config.createTable(priceTable())
|
||||||
await config.createRow()
|
await config.createRow()
|
||||||
const view = await config.createView()
|
const view = await config.createView()
|
||||||
let res = await request
|
let res = await request
|
||||||
|
|
|
@ -46,7 +46,6 @@ exports.basicRow = tableId => {
|
||||||
return {
|
return {
|
||||||
name: "Test Contact",
|
name: "Test Contact",
|
||||||
description: "original description",
|
description: "original description",
|
||||||
status: "new",
|
|
||||||
tableId: tableId,
|
tableId: tableId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,9 @@ registerAll(hbsInstance)
|
||||||
* utility function to check if the object is valid
|
* utility function to check if the object is valid
|
||||||
*/
|
*/
|
||||||
function testObject(object) {
|
function testObject(object) {
|
||||||
|
if (object == null) {
|
||||||
|
throw "Unable to process null object"
|
||||||
|
}
|
||||||
// JSON stringify will fail if there are any cycles, stops infinite recursion
|
// JSON stringify will fail if there are any cycles, stops infinite recursion
|
||||||
try {
|
try {
|
||||||
JSON.stringify(object)
|
JSON.stringify(object)
|
||||||
|
|
Loading…
Reference in New Issue