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