diff --git a/packages/server/__mocks__/node-fetch.js b/packages/server/__mocks__/node-fetch.js index 334dc73cb6..1113791ec2 100644 --- a/packages/server/__mocks__/node-fetch.js +++ b/packages/server/__mocks__/node-fetch.js @@ -1,6 +1,6 @@ const fetch = jest.requireActual("node-fetch") -module.exports = async url , opts=> { +module.exports = async (url, opts) => { // mocked data based on url if (url.includes("api/apps")) { return { diff --git a/packages/server/__mocks__/pouchdb.js b/packages/server/build/pouchdb.js similarity index 86% rename from packages/server/__mocks__/pouchdb.js rename to packages/server/build/pouchdb.js index bb63ca6446..16942a7a86 100644 --- a/packages/server/__mocks__/pouchdb.js +++ b/packages/server/build/pouchdb.js @@ -3,6 +3,7 @@ function CouchDB() { this.allDocs = jest.fn(() => ({ rows: [] })) this.put = jest.fn() this.remove = jest.fn() + this.plugin = jest.fn() } module.exports = CouchDB diff --git a/packages/server/src/integrations/tests/couchdb.spec.js b/packages/server/src/integrations/tests/couchdb.spec.js index fc84f4ace9..cfe522c617 100644 --- a/packages/server/src/integrations/tests/couchdb.spec.js +++ b/packages/server/src/integrations/tests/couchdb.spec.js @@ -1,6 +1,13 @@ const PouchDB = require("pouchdb") const CouchDBIntegration = require("../couchdb") -jest.mock("pouchdb") +jest.mock("pouchdb", () => function CouchDBMock() { + this.post = jest.fn() + this.allDocs = jest.fn(() => ({ rows: [] })) + this.put = jest.fn() + this.remove = jest.fn() + this.plugin = jest.fn() +}) + class TestConfiguration { constructor(config = {}) { diff --git a/packages/server/src/integrations/tests/rest.spec.js b/packages/server/src/integrations/tests/rest.spec.js index 065d8263d1..db8749baa1 100644 --- a/packages/server/src/integrations/tests/rest.spec.js +++ b/packages/server/src/integrations/tests/rest.spec.js @@ -1,6 +1,6 @@ const fetch = require("node-fetch") const RestIntegration = require("../rest") -jest.mock("node-fetch", () => jest.fn(() => ({ json: jest.fn() }))) +jest.mock("node-fetch", () => jest.fn(() => ({ json: jest.fn(), text: jest.fn() }))) class TestConfiguration { constructor(config = {}) { @@ -44,13 +44,13 @@ describe("REST Integration", () => { path: "/api", queryString: "?test=1", headers: { - Accept: "application/json" + Accept: "text/html" } } const response = await config.integration.read(query) expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, { headers: { - Accept: "application/json" + Accept: "text/html" } }) }) diff --git a/packages/server/src/middleware/tests/authenticated.spec.js b/packages/server/src/middleware/tests/authenticated.spec.js index 26c9e3f15d..fe7e592528 100644 --- a/packages/server/src/middleware/tests/authenticated.spec.js +++ b/packages/server/src/middleware/tests/authenticated.spec.js @@ -2,7 +2,6 @@ const { AuthTypes } = require("../../constants") const authenticatedMiddleware = require("../authenticated") const jwt = require("jsonwebtoken") jest.mock("jsonwebtoken") -jest.dontMock("pouchdb") class TestConfiguration { constructor(middleware) {