diff --git a/packages/server/__mocks__/airtable.js b/packages/server/__mocks__/airtable.js new file mode 100644 index 0000000000..4a4d413978 --- /dev/null +++ b/packages/server/__mocks__/airtable.js @@ -0,0 +1,15 @@ +class Airtable { + constructor() {} + + base() { + return () => ({ + query: jest.fn(), + create: jest.fn(), + select: jest.fn(), + update: jest.fn(), + destroy: jest.fn(), + }) + } +} + +module.exports = Airtable diff --git a/packages/server/src/integrations/airtable.js b/packages/server/src/integrations/airtable.js index 37e552a7b8..02190fd5d5 100644 --- a/packages/server/src/integrations/airtable.js +++ b/packages/server/src/integrations/airtable.js @@ -66,6 +66,7 @@ class AirtableIntegration { constructor(config) { this.config = config this.client = new Airtable(config).base(config.base) + console.log(new Airtable().base()) } async create(query) { diff --git a/packages/server/src/integrations/tests/TestConfiguration.js b/packages/server/src/integrations/tests/TestConfiguration.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/server/src/integrations/tests/airtable.spec.js b/packages/server/src/integrations/tests/airtable.spec.js index e69de29bb2..ee3622db5e 100644 --- a/packages/server/src/integrations/tests/airtable.spec.js +++ b/packages/server/src/integrations/tests/airtable.spec.js @@ -0,0 +1,39 @@ +const Airtable = require("airtable") +const { ElectronHttpExecutor } = require("electron-updater/out/electronHttpExecutor") +const { integration } = require("../airtable") + +jest.mock("airtable") + +class TestConfiguration { + constructor(config = {}) { + this.integration = new integration(config) + } +} + +describe("Airtable Integration", () => { + let config + + beforeEach(() => { + config = new TestConfiguration() + }) + + it("calls the create method with the correct params", async () => { + const response = await config.integration.create({ + table: "test", + json: "" + }) + expect(Airtable.create).toHaveBeenCalledWith({}) + }) + + it("calls the read method with the correct params", () => { + + }) + + it("calls the update method with the correct params", () => { + + }) + + it("calls the delete method with the correct params", () => { + + }) +}) \ No newline at end of file diff --git a/packages/server/src/integrations/tests/postgres.spec.js b/packages/server/src/integrations/tests/postgres.spec.js new file mode 100644 index 0000000000..c991ead14f --- /dev/null +++ b/packages/server/src/integrations/tests/postgres.spec.js @@ -0,0 +1,39 @@ + +const Airtable = require("airtable") +const { ElectronHttpExecutor } = require("electron-updater/out/electronHttpExecutor") +const AirtableIntegration = require("../airtable") +jest.mock("airtable") + +class TestConfiguration { + constructor(config = {}) { + this.integration = new AirtableIntegration.integration(config) + } +} + +describe("Airtable Integration", () => { + let config + + beforeEach(() => { + config = new TestConfiguration() + }) + + it("calls the create method with the correct params", async () => { + const response = await config.integration.create({ + table: "test", + json: "" + }) + expect(config.integration.client.create).toHaveBeenCalledWith({}) + }) + + it("calls the read method with the correct params", () => { + + }) + + it("calls the update method with the correct params", () => { + + }) + + it("calls the delete method with the correct params", () => { + + }) +}) \ No newline at end of file