Fixing test cases.
This commit is contained in:
parent
a64ce3f55a
commit
7c7e3da2ab
|
@ -82,7 +82,7 @@ describe("/datasources", () => {
|
||||||
entityId: "users",
|
entityId: "users",
|
||||||
},
|
},
|
||||||
resource: {
|
resource: {
|
||||||
fields: ["name", "age"],
|
fields: ["users.name", "users.age"],
|
||||||
},
|
},
|
||||||
filters: {
|
filters: {
|
||||||
string: {
|
string: {
|
||||||
|
@ -94,7 +94,7 @@ describe("/datasources", () => {
|
||||||
.expect(200)
|
.expect(200)
|
||||||
// this is mock data, can't test it
|
// this is mock data, can't test it
|
||||||
expect(res.body).toBeDefined()
|
expect(res.body).toBeDefined()
|
||||||
expect(pg.queryMock).toHaveBeenCalledWith(`select "name", "age" from "users" where "users"."name" like $1 limit $2`, ["John%", 5000])
|
expect(pg.queryMock).toHaveBeenCalledWith(`select "users"."name" as "users.name", "users"."age" as "users.age" from "users" where "users"."name" like $1 limit $2`, ["John%", 5000])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -62,12 +62,13 @@ describe("SQL query builder", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should test a read with specific columns", () => {
|
it("should test a read with specific columns", () => {
|
||||||
|
const nameProp = `${TABLE_NAME}.name`, ageProp = `${TABLE_NAME}.age`
|
||||||
const query = sql._query(generateReadJson({
|
const query = sql._query(generateReadJson({
|
||||||
fields: ["name", "age"]
|
fields: [nameProp, ageProp]
|
||||||
}))
|
}))
|
||||||
expect(query).toEqual({
|
expect(query).toEqual({
|
||||||
bindings: [limit],
|
bindings: [limit],
|
||||||
sql: `select "name", "age" from "${TABLE_NAME}" limit $1`
|
sql: `select "${TABLE_NAME}"."name" as "${nameProp}", "${TABLE_NAME}"."age" as "${ageProp}" from "${TABLE_NAME}" limit $1`
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue