Files
outline/server/utils/oauth.test.ts
Hemachandar 142985c6d7 Move Document event writing to model layer (#9790)
* documents.restore, documents.unarchive

* documents.templatize

* documents.archive

* documents.unpublish

* documents.create, documents.update

* documents.title_change event

* documents.move

* documents.delete

* tsc, tests

* tsc

* Copilot feedback

---------

Co-authored-by: Tom Moor <tom@getoutline.com>
2025-11-23 20:40:45 +01:00

32 lines
767 B
TypeScript

import fetchMock from "jest-fetch-mock";
import OAuthClient from "./oauth";
class MinimalOAuthClient extends OAuthClient {
endpoints = {
authorize: "http://example.com/authorize",
token: "http://example.com/token",
userinfo: "http://example.com/userinfo",
};
}
beforeEach(() => {
fetchMock.resetMocks();
});
describe("userInfo", () => {
it("should work with empty-body 401 Unauthorized responses", async () => {
fetchMock.mockResponseOnce("", {
status: 401,
statusText: "unauthorized",
});
const client = new MinimalOAuthClient("clientid", "clientsecret");
try {
expect.assertions(1);
await client.userInfo("token");
} catch (e) {
expect(e.id).toBe("authentication_required");
}
});
});