Test fixes
This commit is contained in:
parent
9c169087e6
commit
adbf90887e
|
@ -1,6 +1,9 @@
|
||||||
import env from "../src/environment"
|
import env from "../src/environment"
|
||||||
import { mocks } from "./utilities"
|
import { mocks } from "./utilities"
|
||||||
|
|
||||||
|
// must explicitly enable fetch mock
|
||||||
|
mocks.fetch.enable()
|
||||||
|
|
||||||
// mock all dates to 2020-01-01T00:00:00.000Z
|
// mock all dates to 2020-01-01T00:00:00.000Z
|
||||||
// use tk.reset() to use real dates in individual tests
|
// use tk.reset() to use real dates in individual tests
|
||||||
import tk from "timekeeper"
|
import tk from "timekeeper"
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
const mockFetch = jest.fn()
|
const mockFetch = jest.fn()
|
||||||
jest.mock("node-fetch", () => mockFetch)
|
|
||||||
|
|
||||||
export default mockFetch
|
const enable = () => {
|
||||||
|
jest.mock("node-fetch", () => mockFetch)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
...mockFetch,
|
||||||
|
enable,
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import { createMockContext } from "@shopify/jest-koa-mocks"
|
import { createMockContext, createMockCookies } from "@shopify/jest-koa-mocks"
|
||||||
import { BBContext } from "@budibase/types"
|
import { BBContext } from "@budibase/types"
|
||||||
|
|
||||||
export const newContext = (): BBContext => {
|
export const newContext = (): BBContext => {
|
||||||
const ctx = createMockContext()
|
const ctx = createMockContext()
|
||||||
return {
|
return {
|
||||||
...ctx,
|
...ctx,
|
||||||
|
cookies: createMockCookies(),
|
||||||
request: {
|
request: {
|
||||||
...ctx.request,
|
...ctx.request,
|
||||||
body: {},
|
body: {},
|
||||||
|
|
|
@ -45,11 +45,11 @@ const PUBLIC_ENDPOINTS = [
|
||||||
method: "POST",
|
method: "POST",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
route: "api/system/environment",
|
route: "/api/system/environment",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
route: "api/system/status",
|
route: "/api/system/status",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
// TODO: This should be an internal api
|
// TODO: This should be an internal api
|
||||||
|
|
|
@ -14,6 +14,9 @@ env._set("DISABLE_ACCOUNT_PORTAL", false)
|
||||||
|
|
||||||
import { mocks } from "@budibase/backend-core/tests"
|
import { mocks } from "@budibase/backend-core/tests"
|
||||||
|
|
||||||
|
// must explicitly enable fetch mock
|
||||||
|
mocks.fetch.enable()
|
||||||
|
|
||||||
// mock all dates to 2020-01-01T00:00:00.000Z
|
// mock all dates to 2020-01-01T00:00:00.000Z
|
||||||
// use tk.reset() to use real dates in individual tests
|
// use tk.reset() to use real dates in individual tests
|
||||||
const tk = require("timekeeper")
|
const tk = require("timekeeper")
|
||||||
|
|
Loading…
Reference in New Issue