fix unit tests

This commit is contained in:
Martin McKeaveney 2020-10-15 21:47:20 +01:00
parent fd0841380c
commit 0cbcfe4e0c
1 changed files with 24 additions and 11 deletions

View File

@ -18,6 +18,7 @@ describe("/views", () => {
const createView = async (config = {
name: "TestView",
field: "Price",
calculation: "stats",
tableId: table._id
}) =>
await request
@ -65,20 +66,30 @@ describe("/views", () => {
expect(updatedTable.views).toEqual({
TestView: {
field: "Price",
calculation: "stats",
tableId: table._id,
filters: [],
schema: {
name: {
type: "string",
constraints: {
type: "string"
},
sum: {
type: "number",
},
description: {
min: {
type: "number",
},
max: {
type: "number",
},
count: {
type: "number",
},
sumsqr: {
type: "number",
},
avg: {
type: "number",
},
field: {
type: "string",
constraints: {
type: "string"
},
},
}
}
@ -123,7 +134,7 @@ describe("/views", () => {
Price: 4000
})
const res = await request
.get(`/api/views/TestView?stats=true`)
.get(`/api/views/TestView?calculation=stats`)
.set(defaultHeaders(app._id, instance._id))
.expect('Content-Type', /json/)
.expect(200)
@ -133,6 +144,7 @@ describe("/views", () => {
it("returns data for the created view using a group by", async () => {
await createView({
calculation: "stats",
name: "TestView",
field: "Price",
groupBy: "Category",
@ -154,10 +166,11 @@ describe("/views", () => {
Category: "Two"
})
const res = await request
.get(`/api/views/TestView?stats=true&group=Category`)
.get(`/api/views/TestView?calculation=stats&group=Category`)
.set(defaultHeaders(app._id, instance._id))
.expect('Content-Type', /json/)
.expect(200)
expect(res.body.length).toBe(2)
expect(res.body).toMatchSnapshot()
})