Resetting test.
This commit is contained in:
parent
7fb6c0927a
commit
34d6a41042
|
@ -37,12 +37,27 @@ function mockAuthWithNoCookie() {
|
||||||
mockWorker()
|
mockWorker()
|
||||||
jest.mock("@budibase/backend-core", () => {
|
jest.mock("@budibase/backend-core", () => {
|
||||||
const core = jest.requireActual("@budibase/backend-core")
|
const core = jest.requireActual("@budibase/backend-core")
|
||||||
core.db.dbExists = () => true
|
return {
|
||||||
core.cache.user.getUser = () => ({ _id: "us_uuid1" })
|
...core,
|
||||||
core.utils.getAppIdFromCtx = jest.fn()
|
db: {
|
||||||
core.utils.setCookie = jest.fn()
|
...core.db,
|
||||||
core.utils.getCookie = jest.fn()
|
dbExists: () => true,
|
||||||
return core
|
},
|
||||||
|
cache: {
|
||||||
|
user: {
|
||||||
|
getUser: async id => {
|
||||||
|
return {
|
||||||
|
_id: "us_uuid1",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
utils: {
|
||||||
|
getAppIdFromCtx: jest.fn(),
|
||||||
|
setCookie: jest.fn(),
|
||||||
|
getCookie: jest.fn(),
|
||||||
|
},
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,13 +66,30 @@ function mockAuthWithCookie() {
|
||||||
mockWorker()
|
mockWorker()
|
||||||
jest.mock("@budibase/backend-core", () => {
|
jest.mock("@budibase/backend-core", () => {
|
||||||
const core = jest.requireActual("@budibase/backend-core")
|
const core = jest.requireActual("@budibase/backend-core")
|
||||||
core.db.dbExists = () => true
|
return {
|
||||||
core.cache.user.getUser = () => ({ _id: "us_uuid1" })
|
...core,
|
||||||
core.utils.getAppIdFromCtx = () => "app_test"
|
db: {
|
||||||
core.utils.getCookie = () => ({ appId: "app_different", roleId: "PUBLIC" })
|
...core.db,
|
||||||
core.utils.setCookie = jest.fn()
|
dbExists: () => true,
|
||||||
core.utils.clearCookie = jest.fn()
|
},
|
||||||
return core
|
utils: {
|
||||||
|
getAppIdFromCtx: () => {
|
||||||
|
return "app_test"
|
||||||
|
},
|
||||||
|
setCookie: jest.fn(),
|
||||||
|
clearCookie: jest.fn(),
|
||||||
|
getCookie: () => ({ appId: "app_different", roleId: "PUBLIC" }),
|
||||||
|
},
|
||||||
|
cache: {
|
||||||
|
user: {
|
||||||
|
getUser: async id => {
|
||||||
|
return {
|
||||||
|
_id: "us_uuid1",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,16 +177,29 @@ describe("Current app middleware", () => {
|
||||||
mockReset()
|
mockReset()
|
||||||
jest.mock("@budibase/backend-core", () => {
|
jest.mock("@budibase/backend-core", () => {
|
||||||
const core = jest.requireActual("@budibase/backend-core")
|
const core = jest.requireActual("@budibase/backend-core")
|
||||||
core.db.dbExists = () => true
|
return {
|
||||||
core.cache.user.getUser = () => ({ _id: "us_uuid1" })
|
...core,
|
||||||
core.utils.getAppIdFromCtx = () => "app_test"
|
db: {
|
||||||
core.utils.getCookie = () => ({
|
...core.db,
|
||||||
appId: "app_different",
|
dbExists: () => true,
|
||||||
roleId: "PUBLIC",
|
},
|
||||||
})
|
utils: {
|
||||||
core.utils.setCookie = jest.fn()
|
getAppIdFromCtx: () => {
|
||||||
core.utils.clearCookie = jest.fn()
|
return "app_test"
|
||||||
return core
|
},
|
||||||
|
setCookie: jest.fn(),
|
||||||
|
getCookie: jest.fn(),
|
||||||
|
},
|
||||||
|
cache: {
|
||||||
|
user: {
|
||||||
|
getUser: async id => {
|
||||||
|
return {
|
||||||
|
_id: "us_uuid1",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
})
|
})
|
||||||
await checkExpected()
|
await checkExpected()
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue