more branch cov
This commit is contained in:
parent
6698641182
commit
b7a230065b
|
@ -1,6 +1,6 @@
|
||||||
const fetch = jest.requireActual("node-fetch")
|
const fetch = jest.requireActual("node-fetch")
|
||||||
|
|
||||||
module.exports = async url , opts=> {
|
module.exports = async (url, opts) => {
|
||||||
// mocked data based on url
|
// mocked data based on url
|
||||||
if (url.includes("api/apps")) {
|
if (url.includes("api/apps")) {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -3,6 +3,7 @@ function CouchDB() {
|
||||||
this.allDocs = jest.fn(() => ({ rows: [] }))
|
this.allDocs = jest.fn(() => ({ rows: [] }))
|
||||||
this.put = jest.fn()
|
this.put = jest.fn()
|
||||||
this.remove = jest.fn()
|
this.remove = jest.fn()
|
||||||
|
this.plugin = jest.fn()
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = CouchDB
|
module.exports = CouchDB
|
|
@ -1,6 +1,13 @@
|
||||||
const PouchDB = require("pouchdb")
|
const PouchDB = require("pouchdb")
|
||||||
const CouchDBIntegration = require("../couchdb")
|
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 {
|
class TestConfiguration {
|
||||||
constructor(config = {}) {
|
constructor(config = {}) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const fetch = require("node-fetch")
|
const fetch = require("node-fetch")
|
||||||
const RestIntegration = require("../rest")
|
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 {
|
class TestConfiguration {
|
||||||
constructor(config = {}) {
|
constructor(config = {}) {
|
||||||
|
@ -44,13 +44,13 @@ describe("REST Integration", () => {
|
||||||
path: "/api",
|
path: "/api",
|
||||||
queryString: "?test=1",
|
queryString: "?test=1",
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/json"
|
Accept: "text/html"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const response = await config.integration.read(query)
|
const response = await config.integration.read(query)
|
||||||
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
|
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/json"
|
Accept: "text/html"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,7 +2,6 @@ const { AuthTypes } = require("../../constants")
|
||||||
const authenticatedMiddleware = require("../authenticated")
|
const authenticatedMiddleware = require("../authenticated")
|
||||||
const jwt = require("jsonwebtoken")
|
const jwt = require("jsonwebtoken")
|
||||||
jest.mock("jsonwebtoken")
|
jest.mock("jsonwebtoken")
|
||||||
jest.dontMock("pouchdb")
|
|
||||||
|
|
||||||
class TestConfiguration {
|
class TestConfiguration {
|
||||||
constructor(middleware) {
|
constructor(middleware) {
|
||||||
|
|
Loading…
Reference in New Issue