Fixing test cases.

This commit is contained in:
mike12345567 2021-08-06 12:33:04 +01:00
parent a64ce3f55a
commit 7c7e3da2ab
2 changed files with 5 additions and 4 deletions

View File

@ -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])
}) })
}) })

View File

@ -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`
}) })
}) })