import Forgejo from "./api"; import authtoken from "../secrets/user1-accesstoken.json"; const token = authtoken["sha1"]; const username = authtoken["login"]; test("use authentication without setting it ", () => { const api = new Forgejo("http://localhost:3000", "owner_user"); expect(() => api.getTokenAuth()).toThrow(); api.setTokenAuth(token); expect(api.getTokenAuth().getToken()).toBe(token); let headers = api.getTokenAuthHeader(); expect(headers.Authorization).toBe(`token ${token}`); }); test("verify /user API ", async () => { const api = new Forgejo("http://localhost:3000", "owner_user"); api.setTokenAuth(token); let user = await api.getUser(); console.log(user); expect(user["login"]).toBe(username); });