Skip to content

High performance self-hosted photo and video management solution.

716 B
Raw Blame
import { OAuthRawProfile } from 'src/repositories/oauth.repository.js';
import { OAuthProfileLike } from 'test/factories/types.js';
import { newUuid } from 'test/small.factory.js';

export class OAuthProfileFactory {
  private constructor(private value: OAuthRawProfile) {}

  static create(dto: OAuthProfileLike = {}) {
    return OAuthProfileFactory.from(dto).build();
  }

  static from(dto: OAuthProfileLike = {}) {
    const sub = newUuid();
    return new OAuthProfileFactory({
      sub,
      name: 'Name',
      given_name: 'Given',
      family_name: 'Family',
      email: `oauth-${sub}@immich.cloud`,
      email_verified: true,
      ...dto,
    });
  }

  build() {
    return { ...this.value };
  }
}