mirror of
https://github.com/oxynote/oxynote.git
synced 2026-10-17 10:59:20 +02:00
add more unit tests to auth-realtime
This commit is contained in:
parent
3585604f91
commit
95714482e2
|
|
@ -562,6 +562,27 @@ describe("createRoutes", () => {
|
|||
expect(core.updateBranch).toHaveBeenCalledTimes(0)
|
||||
expect(resetConnections).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it("keeps the connections when core is unreachable", async ({
|
||||
expect,
|
||||
}) => {
|
||||
const core = stubCore()
|
||||
core.updateBranch.mockRejectedValue(
|
||||
new Error("connect ECONNREFUSED"),
|
||||
)
|
||||
const { app, resetConnections } = build({ core })
|
||||
|
||||
const res = await app.request(
|
||||
"/documents/doc1/branches/b1",
|
||||
json({ protected: true }),
|
||||
)
|
||||
|
||||
expect(res.status).toBe(500)
|
||||
expect(await res.json()).toEqual({
|
||||
error: "failed to update branch",
|
||||
})
|
||||
expect(resetConnections).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe("DELETE /documents/:documentId/branches/:branchId", () => {
|
||||
|
|
@ -626,6 +647,27 @@ describe("createRoutes", () => {
|
|||
})
|
||||
expect(resetConnections).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it("keeps the connections when core is unreachable", async ({
|
||||
expect,
|
||||
}) => {
|
||||
const core = stubCore()
|
||||
core.deleteBranch.mockRejectedValue(
|
||||
new Error("connect ECONNREFUSED"),
|
||||
)
|
||||
const { app, resetConnections } = build({ core })
|
||||
|
||||
const res = await app.request(
|
||||
"/documents/doc1/branches/b1",
|
||||
{ method: "DELETE" },
|
||||
)
|
||||
|
||||
expect(res.status).toBe(500)
|
||||
expect(await res.json()).toEqual({
|
||||
error: "failed to delete branch",
|
||||
})
|
||||
expect(resetConnections).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe("PUT /documents/:documentId/merge", () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user