Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

680 B
Raw Blame
import { beforeEach, describe, expect, it, vi } from 'vitest';

import { checkAuthMethod } from './utils';

describe('checkAuthMethod', () => {
  beforeEach(() => {
    vi.clearAllMocks();
  });

  it('should pass with valid Better Auth session', () => {
    expect(() =>
      checkAuthMethod({
        betterAuthAuthorized: true,
      }),
    ).not.toThrow();
  });

  it('should throw Unauthorized with no auth params', () => {
    expect(() => checkAuthMethod({})).toThrow();
  });

  it('should throw Unauthorized when betterAuthAuthorized is false', () => {
    expect(() =>
      checkAuthMethod({
        betterAuthAuthorized: false,
      }),
    ).toThrow();
  });
});