fix unit tests
This commit is contained in:
parent
6d22dd40cf
commit
202598a7fa
|
@ -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: {
|
||||
sum: {
|
||||
type: "number",
|
||||
},
|
||||
min: {
|
||||
type: "number",
|
||||
},
|
||||
max: {
|
||||
type: "number",
|
||||
},
|
||||
count: {
|
||||
type: "number",
|
||||
},
|
||||
sumsqr: {
|
||||
type: "number",
|
||||
},
|
||||
avg: {
|
||||
type: "number",
|
||||
},
|
||||
field: {
|
||||
type: "string",
|
||||
constraints: {
|
||||
type: "string"
|
||||
},
|
||||
},
|
||||
description: {
|
||||
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()
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue