airtable tests

This commit is contained in:
Martin McKeaveney 2021-03-12 09:29:27 +00:00
parent 31c0905ade
commit c31e04eb73
5 changed files with 94 additions and 0 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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", () => {
})
})

View File

@ -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", () => {
})
})