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