1
0
Fork 0
mirror of synced 2024-07-02 21:10:43 +12:00

fix up datasources and server tests

This commit is contained in:
Martin McKeaveney 2021-06-17 15:24:52 +01:00
parent 577c62814c
commit 35942d27b4
8 changed files with 23 additions and 22 deletions

View file

@ -37,7 +37,7 @@ Cypress.Commands.add("createApp", name => {
cy.contains("Create app").click() cy.contains("Create app").click()
}) })
.then(() => { .then(() => {
cy.get("[data-cy=new-table]", { cy.contains("Budibase DB", {
timeout: 20000, timeout: 20000,
}).should("be.visible") }).should("be.visible")
}) })
@ -72,7 +72,8 @@ Cypress.Commands.add("createTestTableWithData", () => {
Cypress.Commands.add("createTable", tableName => { Cypress.Commands.add("createTable", tableName => {
// Enter table name // Enter table name
cy.get("[data-cy=new-table]").click() cy.get("Budibase DB")
cy.contains("Create new table").click()
cy.get(".spectrum-Modal").within(() => { cy.get(".spectrum-Modal").within(() => {
cy.get("input").first().type(tableName).blur() cy.get("input").first().type(tableName).blur()
cy.get(".spectrum-ButtonGroup").contains("Create").click() cy.get(".spectrum-ButtonGroup").contains("Create").click()

View file

@ -2,7 +2,7 @@ const mysql = {}
const client = { const client = {
connect: jest.fn(), connect: jest.fn(),
query: jest.fn((query, fn) => { query: jest.fn((query, bindings, fn) => {
fn(null, []) fn(null, [])
}), }),
} }

View file

@ -85,25 +85,25 @@ class SqlServerIntegration extends Sql {
async read(query) { async read(query) {
await this.connect() await this.connect()
const response = await internalQuery(this.client, query.sql) const response = await internalQuery(this.client, query)
return response.recordset return response.recordset
} }
async create(query) { async create(query) {
await this.connect() await this.connect()
const response = await internalQuery(this.client, query.sql) const response = await internalQuery(this.client, query)
return response.recordset || [{ created: true }] return response.recordset || [{ created: true }]
} }
async update(query) { async update(query) {
await this.connect() await this.connect()
const response = await internalQuery(this.client, query.sql) const response = await internalQuery(this.client, query)
return response.recordset || [{ updated: true }] return response.recordset || [{ updated: true }]
} }
async delete(query) { async delete(query) {
await this.connect() await this.connect()
const response = await internalQuery(this.client, query.sql) const response = await internalQuery(this.client, query)
return response.recordset || [{ deleted: true }] return response.recordset || [{ deleted: true }]
} }

View file

@ -79,21 +79,21 @@ class MySQLIntegration extends Sql {
} }
async create(query) { async create(query) {
const results = await internalQuery(this.client, query.sql) const results = await internalQuery(this.client, query)
return results.length ? results : [{ created: true }] return results.length ? results : [{ created: true }]
} }
read(query) { read(query) {
return internalQuery(this.client, query.sql) return internalQuery(this.client, query)
} }
async update(query) { async update(query) {
const results = await internalQuery(this.client, query.sql) const results = await internalQuery(this.client, query)
return results.length ? results : [{ updated: true }] return results.length ? results : [{ updated: true }]
} }
async delete(query) { async delete(query) {
const results = await internalQuery(this.client, query.sql) const results = await internalQuery(this.client, query)
return results.length ? results : [{ deleted: true }] return results.length ? results : [{ deleted: true }]
} }

View file

@ -168,7 +168,7 @@ class PostgresIntegration extends Sql {
return response.rows.length ? response.rows : [{ updated: true }] return response.rows.length ? response.rows : [{ updated: true }]
} }
async delete({ sql }) { async delete(sql) {
const response = await internalQuery(this.client, sql) const response = await internalQuery(this.client, sql)
return response.rows.length ? response.rows : [{ deleted: true }] return response.rows.length ? response.rows : [{ deleted: true }]
} }

View file

@ -20,7 +20,7 @@ describe("MS SQL Server Integration", () => {
const response = await config.integration.create({ const response = await config.integration.create({
sql sql
}) })
expect(config.integration.client.query).toHaveBeenCalledWith(sql) expect(config.integration.client.query).toHaveBeenCalledWith(sql, undefined)
}) })
it("calls the read method with the correct params", async () => { it("calls the read method with the correct params", async () => {
@ -28,7 +28,7 @@ describe("MS SQL Server Integration", () => {
const response = await config.integration.read({ const response = await config.integration.read({
sql sql
}) })
expect(config.integration.client.query).toHaveBeenCalledWith(sql) expect(config.integration.client.query).toHaveBeenCalledWith(sql, undefined)
}) })
describe("no rows returned", () => { describe("no rows returned", () => {

View file

@ -19,7 +19,7 @@ describe("MySQL Integration", () => {
await config.integration.create({ await config.integration.create({
sql sql
}) })
expect(config.integration.client.query).toHaveBeenCalledWith(sql, expect.any(Function)) expect(config.integration.client.query).toHaveBeenCalledWith(sql, undefined, expect.any(Function))
}) })
it("calls the read method with the correct params", async () => { it("calls the read method with the correct params", async () => {
@ -27,7 +27,7 @@ describe("MySQL Integration", () => {
await config.integration.read({ await config.integration.read({
sql sql
}) })
expect(config.integration.client.query).toHaveBeenCalledWith(sql, expect.any(Function)) expect(config.integration.client.query).toHaveBeenCalledWith(sql, undefined, expect.any(Function))
}) })
it("calls the update method with the correct params", async () => { it("calls the update method with the correct params", async () => {
@ -35,7 +35,7 @@ describe("MySQL Integration", () => {
await config.integration.update({ await config.integration.update({
sql sql
}) })
expect(config.integration.client.query).toHaveBeenCalledWith(sql, expect.any(Function)) expect(config.integration.client.query).toHaveBeenCalledWith(sql, undefined, expect.any(Function))
}) })
it("calls the delete method with the correct params", async () => { it("calls the delete method with the correct params", async () => {
@ -43,7 +43,7 @@ describe("MySQL Integration", () => {
await config.integration.delete({ await config.integration.delete({
sql sql
}) })
expect(config.integration.client.query).toHaveBeenCalledWith(sql, expect.any(Function)) expect(config.integration.client.query).toHaveBeenCalledWith(sql, undefined, expect.any(Function))
}) })
describe("no rows returned", () => { describe("no rows returned", () => {

View file

@ -20,7 +20,7 @@ describe("Postgres Integration", () => {
const response = await config.integration.create({ const response = await config.integration.create({
sql sql
}) })
expect(pg.queryMock).toHaveBeenCalledWith(sql) expect(pg.queryMock).toHaveBeenCalledWith(sql, undefined)
}) })
it("calls the read method with the correct params", async () => { it("calls the read method with the correct params", async () => {
@ -28,7 +28,7 @@ describe("Postgres Integration", () => {
const response = await config.integration.read({ const response = await config.integration.read({
sql sql
}) })
expect(pg.queryMock).toHaveBeenCalledWith(sql) expect(pg.queryMock).toHaveBeenCalledWith(sql, undefined)
}) })
it("calls the update method with the correct params", async () => { it("calls the update method with the correct params", async () => {
@ -36,7 +36,7 @@ describe("Postgres Integration", () => {
const response = await config.integration.update({ const response = await config.integration.update({
sql sql
}) })
expect(pg.queryMock).toHaveBeenCalledWith(sql) expect(pg.queryMock).toHaveBeenCalledWith(sql, undefined)
}) })
it("calls the delete method with the correct params", async () => { it("calls the delete method with the correct params", async () => {
@ -44,7 +44,7 @@ describe("Postgres Integration", () => {
await config.integration.delete({ await config.integration.delete({
sql sql
}) })
expect(pg.queryMock).toHaveBeenCalledWith(sql) expect(pg.queryMock).toHaveBeenCalledWith(sql, undefined)
}) })
describe("no rows returned", () => { describe("no rows returned", () => {